Module: StompBox::Authentication
- Defined in:
- app/authentication.rb
Instance Method Summary collapse
- #authenticate(username, password) ⇒ Object
- #authenticated? ⇒ Boolean
- #login_path ⇒ Object
- #logout ⇒ Object
- #require_authentication ⇒ Object
- #skip_authentication ⇒ Object
Instance Method Details
#authenticate(username, password) ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/authentication.rb', line 31 def authenticate(username, password) return false if username.nil? || password.nil? authenticator = TorqueBox::Authentication.default authenticator.authenticate(username, password) do session[:user] = username end end |
#authenticated? ⇒ Boolean
27 28 29 |
# File 'app/authentication.rb', line 27 def authenticated? !session[:user].nil? end |
#login_path ⇒ Object
23 24 25 |
# File 'app/authentication.rb', line 23 def login_path "#{request.script_name}/login" end |
#logout ⇒ Object
49 50 51 52 |
# File 'app/authentication.rb', line 49 def logout session[:user] = nil redirect login_path end |
#require_authentication ⇒ Object
43 44 45 46 47 |
# File 'app/authentication.rb', line 43 def require_authentication return if request.env['SKIP_AUTH'] return if authenticated? redirect login_path end |
#skip_authentication ⇒ Object
39 40 41 |
# File 'app/authentication.rb', line 39 def skip_authentication request.env['SKIP_AUTH'] = true end |