设计:注册登录尝试 [英] Devise: Registering log in attempts

查看:132
本文介绍了设计:注册登录尝试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 devise 的Rails 3.0项目,我已被要求在DB中登录每次成功的登录和每次失败的尝试。

I have a Rails 3.0 project using devise and I've been requested to register in DB every succesful login and every failed attempt.

设计 文档我想我必须扩展 FailureApp 但是示例只是重定向用户,而不是使用模型。在 stackoverflow 中,我刚刚发现,但它仍然没有得到答复,这是不令人鼓舞的。

From the devise documentation I think I'd have to extend FailureApp but the examples are just redirecting users and not using the model at all. In stackoverflow I've just found this question but it remained unanswered, which is not encouraging

任何人都可以告诉我,如果我在这个方法是正确的或者不能这样做,或者如果有一些更容易的替代品,我会失踪?

Can anyone tell me if I'm correct in this approach or it can't be done this way, or if there is some easier alternative I'm missing?

(我知道还没有代码,我只是

(I know there is no code yet, I'm just looking for a small guidance before diving in)

谢谢。

推荐答案

修改Devise :: SessionsController做你的肮脏的工作会做的伎俩。

Modifying Devise::SessionsController to do your dirty work will do the trick.

只需将该文件复制到你的app / controllers / devise / sessions_controller.rb

Simply copy that file into your app/controllers/devise/sessions_controller.rb

一旦你这样做,只需添加一些代码到用户成功登录的地方,他无法登录,这将做你想要的。

Once you've done that, just add some code to where the user successfully logs in and where he fails to log in that will do what you want.

您可能想要创建一个新的模型登录记录。

You'll probably want to create a new model for tracking login records.

这篇关于设计:注册登录尝试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆