Skip to content

Authentication Action based on field in user table #1211

Answered by warcooft
Ty120301 asked this question in Q&A
Discussion options

You must be logged in to vote

You can override the default actions using the setting package. For example:

 setting('Auth.actions', [
     'register' => \App\Authentication\Actions\EmailActivator::class, // default null
     'login'    => null, // replace with your custom actions
 ]);

This config applies globally.

If you want shield to perform actions based on user preferences, you should customize the $startUpAction.
To enable this, you can replace the following line

$actionClass = setting('Auth.actions')[$type] ?? null;
with

$actionClass = (service('settings')->get('Auth.actions', (string) $user->id) ?? setting('Auth.actions'))[$

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Ty120301
Comment options

@grimpirate
Comment options

Answer selected by Ty120301
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants