设计重置认证令牌

时间:2017-07-17 20:15:48

标签: ruby-on-rails ruby devise

我正在使用Devise,我有一个authentication_token,我在API调用的标题中传递

如何在用户退出时重置该令牌?

我希望每次登录时都会生成一个新令牌。

1 个答案:

答案 0 :(得分:0)

您可以尝试在模型上使用 after_database_authentication 回调。

def after_database_authentication
  self.update_attribute(:auth_token, generated_token)
end

def generated_token
   ...
end