Clicking twice to Login
up vote
0
down vote
favorite
I'm using Laravel Socialite, specifically the Google driver to allow people to Login / Register on my website. I've got a really annoying issue where in order to be redirected to the dashboard, you must click the Login button twice.
$existingUser = Account::where('email', $user->email)->first();
if($existingUser)
Auth::login($existingUser, true);
else
$newUser = new Account();
$newUser->id = strtotime(date('Ymdhis'));
$newUser->name = $user->name;
$newUser->email = $user->email;
$newUser->google_auth_id = $user->id;
$newUser->save();
Auth::login($newUser, true);
return Redirect::to('/');
}
Above is the code I have in my LoginController, it checks for an existing account, if one is found, it logs in and if one can't be found, it creates a new account and then logs that in. In both instances, you must click the button twice to be actually logged in. If it creates a new account, clicking it first does actually add the new account to the database but you then must click it again to be taken to the dashboard.
I have tried return Redirect::intended('/') but that made no difference.
php laravel
add a comment |
up vote
0
down vote
favorite
I'm using Laravel Socialite, specifically the Google driver to allow people to Login / Register on my website. I've got a really annoying issue where in order to be redirected to the dashboard, you must click the Login button twice.
$existingUser = Account::where('email', $user->email)->first();
if($existingUser)
Auth::login($existingUser, true);
else
$newUser = new Account();
$newUser->id = strtotime(date('Ymdhis'));
$newUser->name = $user->name;
$newUser->email = $user->email;
$newUser->google_auth_id = $user->id;
$newUser->save();
Auth::login($newUser, true);
return Redirect::to('/');
}
Above is the code I have in my LoginController, it checks for an existing account, if one is found, it logs in and if one can't be found, it creates a new account and then logs that in. In both instances, you must click the button twice to be actually logged in. If it creates a new account, clicking it first does actually add the new account to the database but you then must click it again to be taken to the dashboard.
I have tried return Redirect::intended('/') but that made no difference.
php laravel
if you are using sub domain make sure that your session key start with.it could be a session problem
– mohammad zein
Nov 11 at 18:40
Thanks but I'm not using a subdomain
– JTP
Nov 12 at 3:10
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm using Laravel Socialite, specifically the Google driver to allow people to Login / Register on my website. I've got a really annoying issue where in order to be redirected to the dashboard, you must click the Login button twice.
$existingUser = Account::where('email', $user->email)->first();
if($existingUser)
Auth::login($existingUser, true);
else
$newUser = new Account();
$newUser->id = strtotime(date('Ymdhis'));
$newUser->name = $user->name;
$newUser->email = $user->email;
$newUser->google_auth_id = $user->id;
$newUser->save();
Auth::login($newUser, true);
return Redirect::to('/');
}
Above is the code I have in my LoginController, it checks for an existing account, if one is found, it logs in and if one can't be found, it creates a new account and then logs that in. In both instances, you must click the button twice to be actually logged in. If it creates a new account, clicking it first does actually add the new account to the database but you then must click it again to be taken to the dashboard.
I have tried return Redirect::intended('/') but that made no difference.
php laravel
I'm using Laravel Socialite, specifically the Google driver to allow people to Login / Register on my website. I've got a really annoying issue where in order to be redirected to the dashboard, you must click the Login button twice.
$existingUser = Account::where('email', $user->email)->first();
if($existingUser)
Auth::login($existingUser, true);
else
$newUser = new Account();
$newUser->id = strtotime(date('Ymdhis'));
$newUser->name = $user->name;
$newUser->email = $user->email;
$newUser->google_auth_id = $user->id;
$newUser->save();
Auth::login($newUser, true);
return Redirect::to('/');
}
Above is the code I have in my LoginController, it checks for an existing account, if one is found, it logs in and if one can't be found, it creates a new account and then logs that in. In both instances, you must click the button twice to be actually logged in. If it creates a new account, clicking it first does actually add the new account to the database but you then must click it again to be taken to the dashboard.
I have tried return Redirect::intended('/') but that made no difference.
php laravel
php laravel
asked Nov 10 at 20:56
JTP
297
297
if you are using sub domain make sure that your session key start with.it could be a session problem
– mohammad zein
Nov 11 at 18:40
Thanks but I'm not using a subdomain
– JTP
Nov 12 at 3:10
add a comment |
if you are using sub domain make sure that your session key start with.it could be a session problem
– mohammad zein
Nov 11 at 18:40
Thanks but I'm not using a subdomain
– JTP
Nov 12 at 3:10
if you are using sub domain make sure that your session key start with
. it could be a session problem– mohammad zein
Nov 11 at 18:40
if you are using sub domain make sure that your session key start with
. it could be a session problem– mohammad zein
Nov 11 at 18:40
Thanks but I'm not using a subdomain
– JTP
Nov 12 at 3:10
Thanks but I'm not using a subdomain
– JTP
Nov 12 at 3:10
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53243333%2fclicking-twice-to-login%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
if you are using sub domain make sure that your session key start with
.it could be a session problem– mohammad zein
Nov 11 at 18:40
Thanks but I'm not using a subdomain
– JTP
Nov 12 at 3:10