Skip to content

Instantly share code, notes, and snippets.

@denmarkin
Created May 4, 2011 18:50
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save denmarkin/955767 to your computer and use it in GitHub Desktop.
Save denmarkin/955767 to your computer and use it in GitHub Desktop.
Custom overwrite for Device::SessionsController
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.'
#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
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