Class: KStor::Controller::Authentication
- Inherits:
-
Object
- Object
- KStor::Controller::Authentication
- Defined in:
- lib/kstor/controller/authentication.rb
Overview
Specialized controller for user authentication and sessions.
Instance Method Summary collapse
-
#allowed?(user) ⇒ Boolean
Check if user is allowed to access the application.
-
#authenticate(req) ⇒ KStor::Model::User
Authenticate request user.
-
#initialize(store, session_store) ⇒ KStor::Controller::Authentication
constructor
Create new auth controller.
Constructor Details
#initialize(store, session_store) ⇒ KStor::Controller::Authentication
Create new auth controller.
18 19 20 21 |
# File 'lib/kstor/controller/authentication.rb', line 18 def initialize(store, session_store) @store = store @sessions = session_store end |
Instance Method Details
#allowed?(user) ⇒ Boolean
Check if user is allowed to access the application.
45 46 47 |
# File 'lib/kstor/controller/authentication.rb', line 45 def allowed?(user) user.status == 'new' || user.status == 'active' end |
#authenticate(req) ⇒ KStor::Model::User
Authenticate request user.
Request may either contain a login/password, or a session ID.
33 34 35 36 37 38 39 |
# File 'lib/kstor/controller/authentication.rb', line 33 def authenticate(req) if @store.users? unlock_user(req) else create_first_user(req) end end |