summaryrefslogtreecommitdiff
path: root/app/controllers/sessions_controller.rb
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-03-05 21:08:07 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-03-05 21:08:07 -0500
commit11b6cab4a9a7d14e6b58c6a16f471aabaa42247f (patch)
tree2bfde1e22d5f93529cd2cf79b795fc8b574f72be /app/controllers/sessions_controller.rb
parent0b9460c1af2619a6158141b01ba77836cc8a9e74 (diff)
parent0d710239a765787f10de304edc438de2dfaa9824 (diff)
Merge branch 'clean'
Conflicts: app/controllers/sessions_controller.rb app/views/sessions/new.html.erb config/routes.rb
Diffstat (limited to 'app/controllers/sessions_controller.rb')
-rw-r--r--app/controllers/sessions_controller.rb26
1 files changed, 24 insertions, 2 deletions
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index 9e539ac..b5ea29b 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -1,19 +1,24 @@
class SessionsController < ApplicationController
+ before_action :set_session, only: [:destroy]
# GET /sessions/new
def new
@user = User.new
+ #@session = Session.new
end
# POST /sessions
+ # POST /sessions.json
def create
# find the user...
@user = User.find_by(email: params[:session][:email].downcase)
+ #@session = Session.new(@user)
# ... and create a new session
respond_to do |format|
if @user && @user.authenticate(params[:session][:password])
sign_in @user
format.html { redirect_to root_path }
+ #format.json { #TODO }
else
format.html { render action: 'new' }
format.json { render json: @user.errors, status: :unprocessable_entity }
@@ -21,9 +26,26 @@ class SessionsController < ApplicationController
end
end
- # DELETE /sessions/current
+ # DELETE /sessions/1
+ # DELETE /sessions/1.json
def destroy
+ #@session.destroy
sign_out
- redirect_to root_path
+ respond_to do |format|
+ format.html { redirect_to root_path }
+ format.json { head :no_content }
+ end
+ end
+
+ private
+
+ # Use callbacks to share common setup or constraints between actions.
+ def set_session
+ #@session = Session.find(cookies[:remember_token])
+ end
+
+ # Never trust parameters from the scary internet, only allow the white list through.
+ def session_params
+ params.require(:session).permit(:session_email, :session_password)
end
end