Module: Veri::Authentication
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/veri/controllers/concerns/authentication.rb
Instance Method Summary collapse
- #current_session ⇒ Object
- #current_user ⇒ Object
- #log_in(authenticatable) ⇒ Object
- #log_out ⇒ Object
- #logged_in? ⇒ Boolean
- #return_path ⇒ Object
- #shapeshifter? ⇒ Boolean
Instance Method Details
#current_session ⇒ Object
29 30 31 32 33 |
# File 'lib/veri/controllers/concerns/authentication.rb', line 29 def current_session token = .encrypted["veri_token"] @current_session ||= Session.find_active(token, resolved_tenant) end |
#current_user ⇒ Object
25 26 27 |
# File 'lib/veri/controllers/concerns/authentication.rb', line 25 def current_user @current_user ||= current_session&.authenticatable end |
#log_in(authenticatable) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/veri/controllers/concerns/authentication.rb', line 35 def log_in(authenticatable) processed_authenticatable = Veri::Inputs::Authenticatable.new( authenticatable, message: "Expected an instance of #{Veri::Configuration.user_model_name}, got `#{authenticatable.inspect}`" ).process return false if processed_authenticatable.locked? token = Veri::Session.establish(processed_authenticatable, request, resolved_tenant) .encrypted.permanent["veri_token"] = { value: token, httponly: true, secure: request.ssl? } reset_memoization true end |
#log_out ⇒ Object
50 51 52 53 54 |
# File 'lib/veri/controllers/concerns/authentication.rb', line 50 def log_out current_session&.terminate .delete("veri_token") reset_memoization end |
#logged_in? ⇒ Boolean
56 57 58 |
# File 'lib/veri/controllers/concerns/authentication.rb', line 56 def logged_in? current_user.present? end |
#return_path ⇒ Object
60 61 62 |
# File 'lib/veri/controllers/concerns/authentication.rb', line 60 def return_path .signed["veri_return_path"] end |
#shapeshifter? ⇒ Boolean
64 65 66 |
# File 'lib/veri/controllers/concerns/authentication.rb', line 64 def shapeshifter? !!current_session&.shapeshifted? end |