Shield how to set up user environment after login |
Hello guys,
Where do you put logic you want to execute once, at login, for each user ? I tried put it in App\Filters\????.php , linked to : $globals = ["before" ... of App\Config\filters.php but it fires at every request. There might be a better way, but which one ? Thanks Eric (10-13-2022, 03:47 AM)foxbille Wrote: Hello guys, So I reply to myself. In App\Config\Filters.php public $filters = [ 'uservars' => ['after' => 'login*'] ]; And in App\Filters\Uservars.php public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { if (auth()->loggedIn()) { ... It works! Eric
Hi @foxbille , I'm not sure I understand what you mean.
But if you want an action to be performed after the user login, it is enough to use events. Here is a list of available Shield events: https://github.com/datamweb/shield/blob/...s.md#login (10-13-2022, 12:06 PM)datamweb Wrote: Hi @foxbille , I'm not sure I understand what you mean.This works for me to add additional session data. How about for the register event to add a DB entry for the user that was just created. Basic info like first and last name. How could I get the userid? |
Welcome Guest, Not a member yet? Register Sign In |