实际上,我使用巫术进行身份验证,设置如下:
- 导轨 3.2.3
- PostgreSQL 9.1.3
- 可以可以
当我单击激活链接时,出现以下错误:
ActiveRecord::RecordNotFound in UsersController#activate
Couldn't find User with id=pJycxPPmoBQw9D2mfW6W
users_controllers.rb
#可以可以
before_filter :require_login, :except => [:not_authenticated, :new, :create, :activate]
load_and_authorize_resource
skip_authorization_check :only => [:new, :create, :activate]
skip_authorize_resource :only => [:new, :create, :activate]
#激活方法
def activate
if (@user = User.load_from_activation_token(params[:id]))
@user.activate!
redirect_to(login_path, :notice => 'Your account is activated.')
else
not_authenticated
end
end
生成令牌
def generate_token(column)
begin
self[column] = SecureRandom.urlsafe_base64
end while User.exists?(column => self[column])
end
魔法源代码中的 load_from_activation_token
def load_from_activation_token(token)
token_attr_name = @sorcery_config.activation_token_attribute_name
token_expiration_date_attr = @sorcery_config.activation_token_expires_at_attribute_name
load_from_token(token, token_attr_name, token_expiration_date_attr)
end
请问我可以帮忙吗?