summaryrefslogtreecommitdiff
path: root/app/controllers/sessions_controller.rb
diff options
context:
space:
mode:
authorguntasgrewal <guntasgrewal@gmail.com>2014-03-04 15:25:58 -0500
committerguntasgrewal <guntasgrewal@gmail.com>2014-03-04 15:25:58 -0500
commite4ae559d8189519586e044238196ee45b2a10c6b (patch)
tree3d4977292aa234ea93ce604095f13d50484250a1 /app/controllers/sessions_controller.rb
parent2f450dd30bb210fdc4cb8899c72e6da945a163ba (diff)
parentda95cb4f0f48731c2713c61f17b522b048647fd1 (diff)
Merge branch 'master' of https://github.com/LukeShu/leaguer
Conflicts: app/assets/stylesheets/scaffolds.css.scss app/views/layouts/application.html.erb db/migrate/20140304043618_create_servers.rb db/migrate/20140304043622_create_matches.rb db/migrate/20140304043631_create_games.rb
Diffstat (limited to 'app/controllers/sessions_controller.rb')
-rw-r--r--app/controllers/sessions_controller.rb32
1 files changed, 19 insertions, 13 deletions
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index 68cb949..fa5d024 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -1,22 +1,28 @@
class SessionsController < ApplicationController
+ # GET /sessions/new
def new
+ if @user.nil?
+ @user = User.new
+ end
end
- # find the user and create a new session
- def create
- user = User.find_by(email: params[:session][:email].downcase)
- if user && user.authenticate(params[:session][:password])
- sign_in user
- redirect_to root_path
- else
- render 'new'
- end
- end
+ # POST /sessions
+ def create
+ # find the user...
+ @user = User.find_by(email: params[:session][:email].downcase)
+ # ... and create a new session
+ if @user && @user.authenticate(params[:session][:password])
+ sign_in @user
+ redirect_to root_path
+ else
+ redirect_to new_session_path
+ end
+ end
+ # DELETE /sessions/current
def destroy
- sign_out
- redirect_to root_path
+ sign_out
+ redirect_to root_path
end
-
end