使用 lockable 或是不使用 lockable 都行
`DeviseController#require_no_authentication` 時會 call `warden.authenticate?`,這時會引發 `Lockable#valid_for_authentication?` 裡面的 `self.failed_attempts += 1`
也就是說當 code 運行到 `Devise::Users::SessionsController#create` 時就已經因為 before_action 而將 `failed_attempts` +1, 這時理論上只需要再 call `warden.authenticated?` 就可以知道是否驗證成功了
請把寄信邏輯寫在這(範例):
```ruby
def create
send_email if !warden.authenticated?
super do |user|
SendAdminLoginToSlack.perform_async(user.id) if user.supervisor?
Sendcloud::SuccessfulLoginSender.perform_async(user.id) if login_with_different_ip?(user)
end
flash.delete :notice
end
```
沒有留言:
張貼留言