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.










share|improve this question





















  • 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














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.










share|improve this question





















  • 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












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.










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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
















  • 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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














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





















































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







這個網誌中的熱門文章

What does pagestruct do in Eviews?

Dutch intervention in Lombok and Karangasem

Channel Islands