[英]Rails: Devise: Sending an email after user comfirms registration
我的應用程序正在使用Devise,正在發送確認電子郵件,並在用戶點擊確認鏈接后正確確認用戶。 我還想在用戶確認后發送第二封電子郵件。
關於如何延遲確認或兩步確認,有很多建議,但沒有關於我正在尋找什么(我能找到)。
Devise :: Module :: Confirmable文檔告訴我使用的方法是確認!,但我不知道如何做到這一點。 有任何想法嗎?
只需定義一個after_save回調,檢查用戶是否已確認,如果是,則發送電子郵件。
如果要保存幾個CPU周期,可以使用以下內容覆蓋Devise ConfirmationsController:
class ConfirmationsController < Devise::ConfirmationsController
def show
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
if resource.errors.empty?
set_flash_message(:notice, :confirmed) if is_navigational_format?
sign_in(resource_name, resource)
# Send the user a second email
send_post_confirmation_email
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
else
respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render :new }
end
end
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.