Closed danito closed 4 years ago
Hi @danito,
Did you apply the trait and interface to your App\Models\User.php
model as described in the documentation?
https://ldaprecord.com/docs/laravel/auth/quickstart/#database-user-model-setup
Hi,
thanks, I missed the "implements LdapAuthenticatable" (don't do homeschool and try new code, kids). But now I get another error:
Class App\Models\User contains 6 abstract methods and must therefore be declared abstract or implement the remaining methods (LdapRecord\Laravel\LdapImportable::getLdapDomainColumn, LdapRecord\Laravel\LdapImportable::getLdapDomain, LdapRecord\Laravel\LdapImportable::setLdapDomain, ...)
at app/Models/User.php:16
12▕ use LdapRecord\Laravel\Auth\HasLdapUser;
13▕ use LdapRecord\Laravel\Auth\LdapAuthenticatable;
14▕ use LdapRecord\Laravel\Auth\AuthenticatesWithLdap;
15▕
➜ 16▕ class User extends Authenticatable implements LdapAuthenticatable
17▕ {
18▕ use HasApiTokens;
19▕ use HasFactory;
20▕ use HasProfilePhoto;
+1 vendor frames
2 [internal]:0
Whoops\Run::handleShutdown()
Here my App\Models\User:
<?php
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Fortify\TwoFactorAuthenticatable;
use Laravel\Jetstream\HasProfilePhoto;
use Laravel\Sanctum\HasApiTokens;
use LdapRecord\Laravel\Auth\HasLdapUser;
use LdapRecord\Laravel\Auth\LdapAuthenticatable;
use LdapRecord\Laravel\Auth\AuthenticatesWithLdap;
class User extends Authenticatable implements LdapAuthenticatable
{
use HasApiTokens;
use HasFactory;
use HasProfilePhoto;
use Notifiable;
use TwoFactorAuthenticatable;
use HasLdapUser;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'username',
'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password',
'remember_token',
'two_factor_recovery_codes',
'two_factor_secret',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
/**
* The accessors to append to the model's array form.
*
* @var array
*/
protected $appends = [
'profile_photo_url',
];
}
You missed the trait LdapRecord\Laravel\Auth\AuthenticatesWithLdap
.
// app/Models/User.php
// ...
use LdapRecord\Laravel\Auth\LdapAuthenticatable;
use LdapRecord\Laravel\Auth\AuthenticatesWithLdap;
class User extends Authenticatable implements LdapAuthenticatable
{
use AuthenticatesWithLdap;
// ...
}
Environment (please complete the following information):
Laravel: 8 --jet Describe the bug: When trying to login with ActiveDirectory user I get this error. Even when trying to import user: