Class: Arkaan::Authentication::Session
- Inherits:
-
Object
- Object
- Arkaan::Authentication::Session
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- lib/arkaan/authentication/session.rb
Overview
A session represents the connection of the user on our frontend application. Nobody else than our frontend should have access to the session or it’s content (in particular to the token), instead they shall use OAuth2.0. A session shall ONLY be created by a premium application (only our frontend applications are premium).
Instance Attribute Summary collapse
-
#account ⇒ Arkaan::Account
The account connected to the application.
-
#device ⇒ Arkaan::Authentication::Device
The device (computer/mobile) linked to this session.
-
#duration ⇒ Integer
The duration of the session in seconds before it expires.
-
#token ⇒ String
The unique token for this session, used to identify it and be sure the user is connected.
-
#websocket_id ⇒ String
The ID of the websocket the user is connected to.
Instance Method Summary collapse
-
#expired? ⇒ Boolean
Checks if the session is expired (it has a duration, and the duration has passed).
Instance Attribute Details
#account ⇒ Arkaan::Account
Returns the account connected to the application.
26 |
# File 'lib/arkaan/authentication/session.rb', line 26 belongs_to :account, class_name: 'Arkaan::Account', inverse_of: :sessions |
#device ⇒ Arkaan::Authentication::Device
Returns the device (computer/mobile) linked to this session.
29 |
# File 'lib/arkaan/authentication/session.rb', line 29 belongs_to :device, class_name: 'Arkaan::Authentication::Session', inverse_of: :sessions, optional: true |
#duration ⇒ Integer
Returns the duration of the session in seconds before it expires.
22 |
# File 'lib/arkaan/authentication/session.rb', line 22 field :duration, type: Integer, default: 86_400 |
#token ⇒ String
Returns the unique token for this session, used to identify it and be sure the user is connected.
15 |
# File 'lib/arkaan/authentication/session.rb', line 15 field :session_id, type: String |
#websocket_id ⇒ String
Returns the ID of the websocket the user is connected to. It’s not an association because instances are embedded.
19 |
# File 'lib/arkaan/authentication/session.rb', line 19 field :websocket_id, type: String, default: '' |
Instance Method Details
#expired? ⇒ Boolean
Checks if the session is expired (it has a duration, and the duration has passed)
42 43 44 |
# File 'lib/arkaan/authentication/session.rb', line 42 def expired? duration != 0 && created_at + duration.to_f < DateTime.now end |