Closed extraric closed 6 months ago
Ok, I may find my own mistake: in the GroupHandler class where I map AD groups to roles in application I had a $user->save();
line. I thought its required but apparently not, also I thought it never reaches attributes sync lines if auth failed by rules.
class GroupHandler
{
public function handle(LdapUser $ldap, User $user)
{
$groups = $ldap->groups()
->orFilter(function ($q) {
$q->whereStartsWith('cn', 'QkApp_')
->whereStartsWith('cn', 'Quentin_');
})
->recursive()
->get()
->pluck('cn')->flatten()->all();
$roles = Role::all();
$userrole = [];
$mainrole = '-kilépett-';
foreach ($roles as $role) {
if (in_array($role->name, $groups)){
$userrole[] = $role;
}
}
$user->roles()->detach();
foreach ($userrole as $role) {
$user->assignRole($role);
switch ($role->name){
case 'Quentin_EO' : $mainrole = 'Értékesítő'; break;
case 'Quentin_kti_diszpecser' : $mainrole = 'Diszpécser'; break;
}
}
$user->mainrole = $mainrole;
//$user->save(); <-- mistake
$user->last_login = Carbon::now();
}
}
Environment:
Hello!
I am facing the following problem: even if authentication rules are return false (user is not in the required group), user object created in the database, and attributes synced.
rule:
auth.php: