Class: Omniauth::Rails::AuthenticationSession
- Inherits:
-
Object
- Object
- Omniauth::Rails::AuthenticationSession
- Defined in:
- app/models/omniauth/rails/authentication_session.rb
Constant Summary collapse
- EMAIL_KEY =
"email"
- EXPIRE_AT_KEY =
"expire_at"
- EXTRA_KEYS =
%w(name image).freeze
Instance Method Summary collapse
- #authenticated? ⇒ Boolean
- #email ⇒ Object
- #email=(email) ⇒ Object
- #expire_at ⇒ Object
- #expire_at=(expire_at) ⇒ Object
- #expire_in(duration) ⇒ Object
-
#initialize(session) ⇒ AuthenticationSession
constructor
A new instance of AuthenticationSession.
Constructor Details
#initialize(session) ⇒ AuthenticationSession
Returns a new instance of AuthenticationSession.
9 10 11 12 13 |
# File 'app/models/omniauth/rails/authentication_session.rb', line 9 def initialize(session) @session = session reset if expired? freeze end |
Instance Method Details
#authenticated? ⇒ Boolean
27 28 29 |
# File 'app/models/omniauth/rails/authentication_session.rb', line 27 def authenticated? email.present? end |
#email ⇒ Object
31 32 33 |
# File 'app/models/omniauth/rails/authentication_session.rb', line 31 def email data_store.get(EMAIL_KEY) end |
#email=(email) ⇒ Object
35 36 37 |
# File 'app/models/omniauth/rails/authentication_session.rb', line 35 def email=(email) data_store.set(EMAIL_KEY, email) end |
#expire_at ⇒ Object
43 44 45 |
# File 'app/models/omniauth/rails/authentication_session.rb', line 43 def expire_at data_store.get(EXPIRE_AT_KEY) end |
#expire_at=(expire_at) ⇒ Object
47 48 49 |
# File 'app/models/omniauth/rails/authentication_session.rb', line 47 def expire_at=(expire_at) data_store.set(EXPIRE_AT_KEY, expire_at) end |
#expire_in(duration) ⇒ Object
39 40 41 |
# File 'app/models/omniauth/rails/authentication_session.rb', line 39 def expire_in(duration) self.expire_at = (Time.now.to_i + duration) end |