mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-11 13:57:41 -08:00
Allow setting of "ldap_import" through the API (#5218)
* Allow setting of "ldap_import" through the API, this will allow cusom scripts to be made to import data from Active directory using the API, this would allow any field to be filled such as the manager (based on the ID), department etc. * Password fix for LDAP through API
This commit is contained in:
parent
18ef355d2a
commit
c23955d0b5
|
@ -194,7 +194,9 @@ class UsersController extends Controller
|
||||||
$this->authorize('view', User::class);
|
$this->authorize('view', User::class);
|
||||||
$user = new User;
|
$user = new User;
|
||||||
$user->fill($request->all());
|
$user->fill($request->all());
|
||||||
$user->password = bcrypt($request->input('password'));
|
|
||||||
|
$tmp_pass = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20);
|
||||||
|
$user->password = bcrypt($request->get('password', $tmp_pass));
|
||||||
|
|
||||||
if ($user->save()) {
|
if ($user->save()) {
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', (new UsersTransformer)->transformUser($user), trans('admin/users/message.success.create')));
|
return response()->json(Helper::formatStandardApiResponse('success', (new UsersTransformer)->transformUser($user), trans('admin/users/message.success.create')));
|
||||||
|
|
|
@ -35,7 +35,10 @@ class SaveUserRequest extends Request
|
||||||
{
|
{
|
||||||
$rules['first_name'] = 'required|string|min:1';
|
$rules['first_name'] = 'required|string|min:1';
|
||||||
$rules['username'] = 'required_unless:ldap_import,1|string|min:1';
|
$rules['username'] = 'required_unless:ldap_import,1|string|min:1';
|
||||||
$rules['password'] = Setting::passwordComplexityRulesSaving('store');
|
if ($this->request->get('ldap_import') == false)
|
||||||
|
{
|
||||||
|
$rules['password'] = Setting::passwordComplexityRulesSaving('store');
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo
|
||||||
'first_name',
|
'first_name',
|
||||||
'jobtitle',
|
'jobtitle',
|
||||||
'last_name',
|
'last_name',
|
||||||
|
'ldap_import',
|
||||||
'locale',
|
'locale',
|
||||||
'location_id',
|
'location_id',
|
||||||
'manager_id',
|
'manager_id',
|
||||||
|
|
Loading…
Reference in a new issue