我使用自定义控制器进行如下登录:
class Users::SessionsController < Devise::SessionsController
def create
# super
@user = User.where(:email => user_params[:email]).first
if @user.valid_password? user_params[:password]
sign_in(@user)
@current_user = @user # even set current user doesn't make sense
redirect_to '/'
else
render :new
end
end
end
我也尝试使用super
,在数据库级别用户已经过验证,但设计从未设置会话。在这两种情况下,我都看到记录在数据库中更新:
UPDATE `users` SET `current_sign_in_at` = '...', `last_sign_in_at` = '...', `sign_in_count` = .., `updated_at` = '...' WHERE `users`.`id` = 1