Support the ongoing development of Laravel.io →
posted 11 years ago
Authentication

Hi there, I currently have a very strange auth problem. My code is as follows:

public function loginGuest()
{
    if (Auth::attempt(['username' => Input::get('username'), 'password' => Input::get('password')]));
{
    Log::info('Logged user: ' . Auth::user()->username);
    return Redirect::to('/');
}
	
return View::make('guest');
}

So the problem is that Auth::attempt is passing even if the credentials are wrong! Strangely no user is actually logged in, so the code then goes on to fail on the Log::info() line where I try and get the username.

Any ideas its very weird? I should note that I am using Homestead too.

Last updated 3 years ago.
0

Did you add all the filters also try calling logout then having another try

Last updated 3 years ago.
0

Hi thanks for your reply. Yes I have tried placing Auth::logout() just before that code to see fi it helps but no luck. I am not using any filters at this point, just trying to get the log in to work. Temporally I have created my own auth attempt function manually and that works fine, but I would prefer to use the proper one and it bugs me there is an underlying problem here.

Last updated 3 years ago.
0

Found the problem!! I had accidentally put a ; after the () in my if statement!!!! How did I miss that! Hours wasted lol!

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

zefman zefman Joined 30 Dec 2013

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.