I am new on PHP. I have a laravel api and laravel webui in different servers. When i make a request for login in webui, sent it to api and if result is success return laravel/passport token to webui. I stored token in session(in webui auth controller).
AuthController;
Session::put('token', $value['token']);
My CustomAuth Middleware;
class CustomAuth extends Middleware {
public function handle($request, Closure $next, $guard = null){
if (Session::has('token')) {
return $next($request);
} else {
return response(view('pages.unauthorized'));
}
}
}
Payment method;
return redirect()->away($redirectUrl);
And then, when payment is success/fail wirecard returning to my site(callbackUrl). In this section, session data is lost and user redirect to login page. I am not sure whether I am wrong in the auth part or use the session incorrectly. Can i store session data when i redirect? Or how can i change auth part?
Note: success and fail routes has to be in auth middleware. And my all routes in web middleware group. In app/Http/Kernel.php, this line added in 'web'
\Illuminate\Session\Middleware\StartSession::class,