Created
May 4, 2011 18:50
-
-
Save denmarkin/955767 to your computer and use it in GitHub Desktop.
Custom overwrite for Device::SessionsController
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sessions: | |
signed_in: 'Signed in successfully.' | |
signed_in_first_time: "MY CUSTOM WELCOME GREETING. DO NOT FORGET TO READ OUR GUIDELINE!" | |
signed_out: 'Signed out successfully.' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#devise_for :users, :experts, "admin/administrators" | |
devise_for :users, "admin/administrators" | |
devise_for :experts, :controllers => {:sessions => 'sessions'}, :skip => [:sessions] do | |
get '/experts/sign_in' => 'sessions#new', :as => :new_expert_session | |
post '/experts/sign_in' => 'sessions#create', :as => :expert_session | |
get '/experts/sign_out' => 'sessions#destroy', :as => :destroy_expert_session | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SessionsController < Devise::SessionsController | |
def create | |
resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new") | |
if is_navigational_format? | |
if resource.sign_in_count == 1 | |
set_flash_message(:notice, :signed_in_first_time) | |
else | |
set_flash_message(:notice, :signed_in) | |
end | |
end | |
sign_in(resource_name, resource) | |
respond_with resource, :location => redirect_location(resource_name, resource) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment