Module: Authentication
- Extended by:
- ActiveSupport::Concern
- Included in:
- Admin::UsersController, AuthenticationController, My::ConfirmationsController, My::ProfilesController
- Defined in:
- app/controllers/concerns/authentication.rb
Overview
Adds methods for user authentication
Instance Method Summary collapse
- #cookie_data(value) ⇒ Object
- #create_token_for_user(user) ⇒ Object
- #deactivate_token ⇒ Object
- #pop_token ⇒ Object
- #redirect_authenticated_user ⇒ Object
Instance Method Details
#cookie_data(value) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'app/controllers/concerns/authentication.rb', line 37 def (value) { value: value, expires: 1.year.from_now, domain: :all, httponly: true } end |
#create_token_for_user(user) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'app/controllers/concerns/authentication.rb', line 12 def create_token_for_user(user) forced_user = User.find_by(id: user.primary_id) user = forced_user unless forced_user.nil? token = user.tokens.create!(tracking_for_entity) ['token'] = (token.) end |
#deactivate_token ⇒ Object
21 22 23 24 25 |
# File 'app/controllers/concerns/authentication.rb', line 21 def deactivate_token token = Token.find_by(token: ['token'].split(':').last) token&.update(active: false) pop_token end |
#pop_token ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'app/controllers/concerns/authentication.rb', line 27 def pop_token if ['pt'] ['token'] = (['pt']) .delete 'pt', domain: :all else .delete 'token', domain: :all end end |
#redirect_authenticated_user ⇒ Object
7 8 9 |
# File 'app/controllers/concerns/authentication.rb', line 7 def redirect_authenticated_user redirect_to my_path unless current_user.nil? end |