Closed isbkch closed 8 years ago
I need more information. How are your users being created? Are you using the default app/Http/Controllers/Auth/AuthController.php
?
Can you also post your code for your login method?
Users are being added to database manually for now..
My login is heavily inspired from the laravel\framework\src\Illuminate\Foundation\Auth\AuthenticatesUsers.php
It's written in app/Http/Controllers/Auth/AuthController.php
/**
* Handle a login request for admin (Ldap)
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function adminPostLogin(HttpRequest $request)
{
// TODO: validate the credentials
// If the class is using the ThrottlesLogins trait, we can automatically throttle
// the login attempts for this application. We'll key this by the username and
// the IP address of the client making these requests into this application.
$throttles = $this->isUsingThrottlesLoginsTrait();
if ($throttles && $lockedOut = $this->hasTooManyLoginAttempts($request)) {
$this->fireLockoutEvent($request);
return $this->sendLockoutResponse($request);
}
$credentials = $this->getCredentials($request);
if (Auth::guard('admin')->attempt($credentials)) {
return $this->handleUserWasAuthenticated($request, $throttles);
}
// If the login attempt was unsuccessful we will increment the number of attempts
// to login and redirect the user back to the login form. Of course, when this
// user surpasses their maximum number of attempts they will get locked out.
if ($throttles && ! $lockedOut) {
$this->incrementLoginAttempts($request);
}
return $this->sendFailedLoginResponse($request);
}
Hmm it's quite possible that it might be a case sensitivity issue (#L113)? Can you try using an account with the same casing for its username and see if you still experience the issue? Also what type of database are you using?
Hum, here is what I just discovered.
For user "John Doe", the 'username' field in DB contains: "j_doe". But After login, the username is converted into "John Doe". It actually rewrites the row in DB. So the next time I try to login, it tries to insert the full name again "John Doe" but it's already there..
Shouldn't use a temporary table for this instead of writing into the "members" table ?
The members
table? Are you using multiple authentication database tables?
Yes.
But here is what I did to fix it: in config/adldap_auth.php
another developer had added previously
'sync_attributes' => [
'username' => 'cn',
],
So I removed 'username' so nothing is updated... My bad :) Thank you for your time, you can close this
Ah okay so just a configuration issue, no problem :). Good to know, thanks!
The first time I logged in with no issues.
dd(Auth::guard('gardName')->user());
is giving all my user session information So I logged out doingAuth::guard('admin')->logout();
nowdd(Auth::guard('admin')->user());
is returning null. Which means that user is no longed in.Now I tried to login again. But I have an SQL error everytime:
Why am I getting this ? Shouldn't the record be updated if it already exists ?