Import thumbnail photos when LDAP users are created.
This commit is contained in:
		
							parent
							
								
									f3ee8f2d4c
								
							
						
					
					
						commit
						b714652e10
					
				| 
						 | 
					@ -117,7 +117,17 @@ class LdapSessionGuard extends ExternalBaseSessionGuard
 | 
				
			||||||
            'password' => Str::random(32),
 | 
					            'password' => Str::random(32),
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->registrationService->registerUser($details, null, false);
 | 
					        $user = $this->registrationService->registerUser($details, null, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (config('services.ldap.import_thumbnail_photos')) {
 | 
				
			||||||
 | 
					            $imageService = app()->make(ImageService::class);
 | 
				
			||||||
 | 
					            $image = $imageService->saveNewFromBase64Uri('data:image/jpg;base64,'.base64_encode($ldapUserDetails['avatar']), $ldapUserDetails['uid'].'.jpg', 'user');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $user['image_id'] = $image->id;
 | 
				
			||||||
 | 
					            $user->save();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $user;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -89,6 +89,7 @@ class LdapService extends ExternalAuthService
 | 
				
			||||||
            'name'  => $this->getUserResponseProperty($user, $displayNameAttr, $userCn),
 | 
					            'name'  => $this->getUserResponseProperty($user, $displayNameAttr, $userCn),
 | 
				
			||||||
            'dn'    => $user['dn'],
 | 
					            'dn'    => $user['dn'],
 | 
				
			||||||
            'email' => $this->getUserResponseProperty($user, $emailAttr, null),
 | 
					            'email' => $this->getUserResponseProperty($user, $emailAttr, null),
 | 
				
			||||||
 | 
					            'avatar'=> $this->getUserResponseProperty($user, $thumbnailAttr, null),
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($this->config['dump_user_details']) {
 | 
					        if ($this->config['dump_user_details']) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -132,6 +132,8 @@ return [
 | 
				
			||||||
        'group_attribute' => env('LDAP_GROUP_ATTRIBUTE', 'memberOf'),
 | 
					        'group_attribute' => env('LDAP_GROUP_ATTRIBUTE', 'memberOf'),
 | 
				
			||||||
        'remove_from_groups' => env('LDAP_REMOVE_FROM_GROUPS', false),
 | 
					        'remove_from_groups' => env('LDAP_REMOVE_FROM_GROUPS', false),
 | 
				
			||||||
        'tls_insecure' => env('LDAP_TLS_INSECURE', false),
 | 
					        'tls_insecure' => env('LDAP_TLS_INSECURE', false),
 | 
				
			||||||
 | 
					        'import_thumbnail_photos' => env('LDAP_IMPORT_THUMBNAIL_PHOTOS', false),
 | 
				
			||||||
 | 
					        'thumbnail_attribute' => env('LDAP_THUMBNAIL_ATTRIBUTE', 'thumbnailPhoto'),
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
 | 
					
 | 
				
			||||||
];
 | 
					];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue