1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00
heartcombo--devise/app/controllers/sessions_controller.rb

40 lines
886 B
Ruby
Raw Normal View History

class SessionsController < ApplicationController
2009-10-12 07:37:28 -04:00
before_filter :is_devise_resource?
before_filter :require_no_authentication, :only => [ :new, :create ]
2009-10-17 11:10:15 -04:00
# GET /resource/sign_in
def new
2009-10-12 07:37:28 -04:00
unauthenticated! if params[:unauthenticated]
unconfirmed! if params[:unconfirmed]
end
2009-10-17 11:10:15 -04:00
# POST /resource/sign_in
def create
2009-10-18 13:01:56 -04:00
if authenticate(resource_name)
2009-10-11 21:11:58 -04:00
set_flash_message :success, :signed_in
redirect_back_or_to home_or_root_path
else
2009-10-12 07:37:28 -04:00
unauthenticated!
render :new
end
end
2009-10-17 11:10:15 -04:00
# GET /resource/sign_out
def destroy
set_flash_message :success, :signed_out if signed_in?(resource_name)
sign_out(resource_name)
2009-10-11 22:24:57 -04:00
redirect_to root_path
end
2009-10-12 07:37:28 -04:00
protected
def unauthenticated!
set_now_flash_message :failure, :unauthenticated
end
def unconfirmed!
set_now_flash_message :failure, :unconfirmed
2009-10-12 07:37:28 -04:00
end
end