In my project when user Logged in I want that USER don't seen login page again when I click the browser arrow back button it again goes back to login page without logout
in Middleware in ready do code for URL , I mean when user on dashboard and he want to go back with url i prevent user with middleware
but i didn't work for me in browser back button
This is my controller
public function loginUser( Request $request ) {
$validatedData = $request->validate( [
'UserName' => 'required',
'Password' => 'required',
] );
$client = new \GuzzleHttp\Client();
$cookieJar = new \GuzzleHttp\Cookie\CookieJar();
$UserName = $request->input( 'UserName' );
$Password = base64_encode( $request->input( 'Password' ) );
$response = $client->post( 'http://sso.gov.in:0000/SSOREST/SSOAuthJSON', [
'form_params' => [
'UserName' => $UserName,
'Password' => $Password,
],
'cookies' => $cookieJar,
] );
$data = json_decode( $response->getBody(), true );
if ( $data[ 'valid' ] === true ) {
$valid = $data[ 'valid' ];
session( [ 'valid' => $valid ] );
$msg = $data[ 'msg' ];
session( [ 'msg' => $msg ] );
User::updateOrCreate( [
'UserName' => $validatedData[ 'UserName' ],
'Password' => base64_encode( $validatedData[ 'Password' ] ),
] );
return redirect()->route( 'dashboard' );
} else {
return redirect()
->back()->withInput( $request->only( 'UserName' ) )
->with( 'fail', 'Invalid credentials' );
}
}
what should I do now for stoping browser button go back to login page if user on dashboard how to handle this error