我通过电子邮件向用户发送一个私人链接,
= 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
发布于 2015-09-18 16:50:15
实际上,您有两个互补的选项:
SecureRandom.hex
甚至SecureRandom.urlsafe_base64
。跟踪对该特定操作的超文本传输协议请求,如果每分钟的请求数高于5,则按IP阻止用户。https://stackoverflow.com/questions/32641921
复制相似问题