Can I execute custom actions after successful sign in with Devise?

前端 未结 5 2408
春和景丽
春和景丽 2020-12-08 15:01

I have an app that has basic Devise authentication. After sign in, I would like to look up the user account (user belongs_to account, account has_many users), and store tha

5条回答
  •  余生分开走
    2020-12-08 15:41

    I resolved this problem by overriding the create method of the session controller like following

    class Admin::SessionsController < Devise::SessionsController
    
       def create 
         super
         # here goes my code
         # my settings, etc 
         # do something with current_admin.fullname, for example
      end 
    end
    

    In other words, if authentication is successful (by calling super) then I perform my settings.

提交回复
热议问题