diff options
| author | mo khan <mo@mokhan.ca> | 2014-04-11 23:01:32 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-04-11 23:01:32 -0600 |
| commit | 5144cbc728e289cea899b2876863b3ffbc2b4b6e (patch) | |
| tree | 8d9cff5d5b0870301786680cf3a7f9e9986270f3 /app/controllers/sessions_controller.rb | |
| parent | 8e4129c3052ad53601e8e1efc8be90177e02c6c5 (diff) | |
rename logins to sessions.
Diffstat (limited to 'app/controllers/sessions_controller.rb')
| -rw-r--r-- | app/controllers/sessions_controller.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 0000000..6ee923d --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,24 @@ +class SessionsController < ApplicationController + before_filter :load_dependencies + skip_before_filter :ensure_valid_session, only: [:new, :create] + layout 'public' + + def new + end + + def create + if @session = @login_command.run(self) + session[:user_session_id] = @session.id + redirect_to root_path(anchor: '') + else + flash[:error] = I18n.translate(:invalid_credentials) + render :new + end + end + + private + + def load_dependencies(login_command = resolve(:login_command)) + @login_command = login_command + end +end |
