Module: Lato::Sessionable
- Extended by:
- ActiveSupport::Concern
- Included in:
- ApplicationController
- Defined in:
- app/controllers/concerns/lato/sessionable.rb
Instance Method Summary collapse
- #authenticate_session ⇒ Object
- #not_authenticate_session ⇒ Object
- #session_create(user_id) ⇒ Object
- #session_destroy ⇒ Object
Instance Method Details
#authenticate_session ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/concerns/lato/sessionable.rb', line 11 def authenticate_session return true if @session.valid? respond_to do |format| format.html { redirect_to lato.root_path } format.json { render plain: '', status: :unauthorized } end false end |
#not_authenticate_session ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/concerns/lato/sessionable.rb', line 22 def not_authenticate_session return true unless @session.valid? respond_to do |format| format.html { redirect_to lato.root_path } format.json { render plain: '', status: :unauthorized } end false end |
#session_create(user_id) ⇒ Object
33 34 35 36 37 |
# File 'app/controllers/concerns/lato/sessionable.rb', line 33 def session_create(user_id) .encrypted[:lato_session] = { value: Lato::Session.generate_session_per_user(user_id), expires: Lato.config.session_lifetime.from_now } true end |
#session_destroy ⇒ Object
39 40 41 42 43 |
# File 'app/controllers/concerns/lato/sessionable.rb', line 39 def session_destroy .encrypted[:lato_session] = nil true end |