Module: Leech::Handlers::Auth::ServerMethods
- Defined in:
- lib/leech/handlers/auth.rb
Instance Method Summary collapse
-
#authorize(passcode) ⇒ Object
Authorize client session using simple passcode.
-
#authorized? ⇒ Boolean
Is client session authorized?.
Instance Method Details
#authorize(passcode) ⇒ Object
Authorize client session using simple passcode.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/leech/handlers/auth.rb', line 27 def (passcode) if [:passcode].to_s.strip == passcode.to_s.strip Thread.current[:authorized] = true answer("AUTHORIZED\n") logger.info("Client #{info[:uri]} authorized") else Thread.current[:authorized] = false answer("UNAUTHORIZED\n") logger.info("Client #{info[:uri]} unauthorized: invalid passcode") end end |
#authorized? ⇒ Boolean
Returns Is client session authorized?.
41 42 43 |
# File 'lib/leech/handlers/auth.rb', line 41 def !!Thread.current[:authorized] end |