php - Cannot override Laravel Spark authentication with own implementation -


during login process of laravel spark need request token of remote api. api stores exact same users , passwords laravel spark application. therefore need username , non hashed password of user during authentication process.

i thought overriding authenticated method solution problem. in routes/web.php override post /login endpoint , pointing endpoint own logincontroller:

<?php  namespace app\http\controllers\auth;  use illuminate\support\facades\log; use illuminate\http\request; use laravel\spark\http\controllers\auth\logincontroller sparklogincontroller;  class logincontroller extends sparklogincontroller {     /**      * create new login controller instance.      *      * @return void      */     public function __construct()     {         parent::__construct();     }      /**      * handle successful authentication attempt.      *      * @param  request  $request      * @param  \illuminate\contracts\auth\authenticatable  $user      * @return response      */     public function authenticated(request $request, $user)     {         log::info('authenticated method in logincontroller has been called');          return parent::authenticated($request, $user);     } } 

this implementation throws missing argument 2 app\http\controllers\auth\logincontroller::authenticated() exception. somehow laravel not passing user in $user parameter. exception thrown whatever do. removing method out of logincontroller result in same exception thrown in spark logincontroller.

when disable /login endpoint , log $request , $user parameters of authenticated method in spark logincontroller, see $request contains illuminate\http\request::__set_state(array(...)) , $user contains app\user::__set_state(array()). when log same in own controller $request contains illuminate\http\request::__set_state(array(...)) , $user not passed.

it turned out post /login route did not call right function. called auth\logincontroller@authenticated , should call auth\logincontroller@login.

how complete route should look: route::post('/login', 'auth\logincontroller@login');

stupid mistake, maybe in future facing same problem.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -