$user->login() hook

Hi all,

I have a frontend login page and a corresponding hook within my config.php to check if the user, who’s trying to login, exists in our Active Directory. This works fairly well via the panel login page however fails on the frontend login.

'route:before' => function ($route, $path, $method) {
  if($path == 'api/auth/login' && $method == "POST") {
    Ldapcheck::checkLDAPuser($this->request()->get('email'));
  }
}

My question is does $user->login() uses /api/auth/login for checking the user login?
There seems to be a difference between those two login methods. The login controller is pretty much 1:1 from the cookbook recipe.

Thanks,
Flo

No, the login on the frontend is handled by your controller. So your route:before hook does not apply

1 Like

Well that makes sense :smiley: got it working. Thanks @texnixe for the hint!

'route:before' => function ($route, $path, $method) {
   if(($path == 'api/auth/login' OR $path == 'login') && $method == "POST") {
      Ldapcheck::checkLDAPuser($this->request()->get('email'));
   }
}