![](/img/trans.png)
[英]How to get Devise in Rails skip_confirmation to actually not send an email?
[英]Rails Devise and skip_confirmation!, how to avoid autologin
當我使用確認電子郵件中的鏈接來確認我的帳戶時,我被重定向到登錄路徑,這很好。 但是對於某些用戶,我想跳過確認,因此我在驗證collback之前應用了以下代碼:
if foo?
self.skip_confirmation!
end
問題是,當我注冊為該用戶時,我會自動登錄,這有什么辦法防止它發生? 我想跳過確認但不自動登錄。
您可以嘗試覆蓋sign_up
的RegistrationsController
而僅覆蓋sign_up
方法。 在devise來源中對該方法的注釋為“在注冊時登錄用戶。您可以在自己的RegistrationsController中覆蓋此方法” 。 然后,您可以像這樣覆蓋它:
def sign_up(resource_name, resource)
if !foo? # or you could use "if !resource.confirmed?" instead.
super # The current implementation just calls sign_in(resource_name, resource)
end
end
我本人實際上並沒有做到這一點,但希望能有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.