Open DennisKo opened 9 years ago
Hi Dennis, this is how I have implemented it:
class SessionsController < Devise::SessionsController def create resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#failure") sign_in_and_redirect(resource_name, resource) end
def sign_in_and_redirect(resource_or_scope, resource=nil) scope = Devise::Mapping.find_scope!(resource_or_scope) resource ||= resource_or_scope sign_in(scope, resource) unless warden.user(scope) == resource flash[:notice] = "Loggade in." render :template => "shared/ujs/devise_success_login.js.erb" end
def failure render :template => "shared/ujs/devise_errors.js.erb" end end
I am struggling to implement the sessions_controller with this method. How you would you do this?