Do custom action after devise model confirmation

倖福魔咒の 提交于 2019-12-11 02:34:33

问题


I know once the user has confirmed a Confirmable account in devise, I can change the redirect URL with:

def after_confirmation_path_for(resource)
  view_context.admin_dashboard_url_for(subdomain: resource.tenant.subdomain)
end

But if I wanted to call a custom method on the resource after confirmation, how would I do that with devise? I suppose I could stick it in this method...

 def after_confirmation_path_for(resource)
   resource.do_thing_after_confirmation
   view_context.admin_dashboard_url_for(subdomain: resource.tenant.subdomain)
 end

But that doesn't feel right to have this method changing the model.


回答1:


I found a blank method in Devise::Models::Confirmable that is called during the confirm! method. I'm going to override this method in my User resource model and do my work here.

def after_confirmation
end


来源:https://stackoverflow.com/questions/25321481/do-custom-action-after-devise-model-confirmation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!