我通过电子邮件向用户发送私人链接
= link_to user_profile_url(user_token: @user.token, user_id: @user.uid), method: :post
避免让用户再次从移动邮件应用程序登录。如果请求有user_token, user_id
参数,我会允许用户登录。
因为我现在的方法可以在短时间内强力尝试。
避免暴力攻击的最佳做法是什么,谢谢
def get_user_by_token(user_id=nil ,token=nil)
if user_id and token
User.where({id: user_id, token: token}).first
else
nil
end
end
答案 0 :(得分:1)
您基本上有两个补充选项:
SecureRandom.hex
甚至SecureRandom.urlsafe_base64
,其中不仅包括字母和数字,还包括其他字符。