Module: Passwordless::ControllerHelpers
- Included in:
- SessionsController
- Defined in:
- lib/passwordless/controller_helpers.rb
Instance Method Summary collapse
- #authenticate_by_cookie(authenticatable_class) ⇒ Object
- #reset_passwordless_redirect_location!(authenticatable_class) ⇒ Object
- #save_passwordless_redirect_location!(authenticatable_class) ⇒ Object
- #sign_in(authenticatable) ⇒ Object
- #sign_out(authenticatable_class) ⇒ Object
Instance Method Details
#authenticate_by_cookie(authenticatable_class) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/passwordless/controller_helpers.rb', line 3 def (authenticatable_class) key = (authenticatable_class) authenticatable_id = .encrypted[key] return unless authenticatable_id authenticatable_class.find_by(id: authenticatable_id) end |
#reset_passwordless_redirect_location!(authenticatable_class) ⇒ Object
27 28 29 |
# File 'lib/passwordless/controller_helpers.rb', line 27 def reset_passwordless_redirect_location!(authenticatable_class) session.delete session_key(authenticatable_class) end |
#save_passwordless_redirect_location!(authenticatable_class) ⇒ Object
23 24 25 |
# File 'lib/passwordless/controller_helpers.rb', line 23 def save_passwordless_redirect_location!(authenticatable_class) session[session_key(authenticatable_class)] = request.original_url end |
#sign_in(authenticatable) ⇒ Object
11 12 13 14 15 |
# File 'lib/passwordless/controller_helpers.rb', line 11 def sign_in(authenticatable) key = (authenticatable.class) .encrypted.permanent[key] = { value: authenticatable.id } authenticatable end |
#sign_out(authenticatable_class) ⇒ Object
17 18 19 20 21 |
# File 'lib/passwordless/controller_helpers.rb', line 17 def sign_out(authenticatable_class) key = (authenticatable_class) .encrypted.permanent[key] = { value: nil } .delete(key) end |