2009-10-07 20:46:40 -04:00
|
|
|
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-07 20:46:40 -04:00
|
|
|
|
2009-10-17 11:10:15 -04:00
|
|
|
# GET /resource/sign_in
|
2009-10-07 20:46:40 -04:00
|
|
|
def new
|
2009-10-12 07:37:28 -04:00
|
|
|
unauthenticated! if params[:unauthenticated]
|
2009-10-21 09:20:10 -04:00
|
|
|
unconfirmed! if params[:unconfirmed]
|
2009-10-07 20:46:40 -04:00
|
|
|
end
|
|
|
|
|
2009-10-17 11:10:15 -04:00
|
|
|
# POST /resource/sign_in
|
2009-10-07 20:46:40 -04:00
|
|
|
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
|
2009-10-18 13:25:16 -04:00
|
|
|
redirect_back_or_to home_or_root_path
|
2009-10-10 13:14:09 -04:00
|
|
|
else
|
2009-10-12 07:37:28 -04:00
|
|
|
unauthenticated!
|
2009-10-10 13:14:09 -04:00
|
|
|
render :new
|
|
|
|
end
|
2009-10-07 20:46:40 -04:00
|
|
|
end
|
|
|
|
|
2009-10-17 11:10:15 -04:00
|
|
|
# GET /resource/sign_out
|
2009-10-07 20:46:40 -04:00
|
|
|
def destroy
|
2009-10-12 18:20:12 -04:00
|
|
|
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
|
2009-10-07 20:46:40 -04:00
|
|
|
end
|
2009-10-12 07:37:28 -04:00
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def unauthenticated!
|
2009-10-21 09:20:10 -04:00
|
|
|
set_now_flash_message :failure, :unauthenticated
|
|
|
|
end
|
|
|
|
|
|
|
|
def unconfirmed!
|
|
|
|
set_now_flash_message :failure, :unconfirmed
|
2009-10-12 07:37:28 -04:00
|
|
|
end
|
2009-10-18 13:25:16 -04:00
|
|
|
|
2009-10-07 20:46:40 -04:00
|
|
|
end
|