mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Make it possible to edit a user without necessarily updating the users password (closes #1942)
This commit is contained in:
@@ -59,6 +59,7 @@
|
|||||||
|
|
||||||
### General
|
### General
|
||||||
|
|
||||||
|
- It's now possible to edit a user without necessarily updating the users password
|
||||||
- Fixed that when running label printer WebHooks client side (so when `LABEL_PRINTER_RUN_SERVER` = `false`), the setting `LABEL_PRINTER_HOOK_JSON` was ignored (the WebHook data was always sent as form data)
|
- Fixed that when running label printer WebHooks client side (so when `LABEL_PRINTER_RUN_SERVER` = `false`), the setting `LABEL_PRINTER_HOOK_JSON` was ignored (the WebHook data was always sent as form data)
|
||||||
- New translations: (thanks all the translators)
|
- New translations: (thanks all the translators)
|
||||||
- Lithuanian (demo available at <https://lt.demo.grocy.info>)
|
- Lithuanian (demo available at <https://lt.demo.grocy.info>)
|
||||||
|
@@ -120,15 +120,6 @@ $('#user-form input').keydown(function(event)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (GetUriParam("changepw") === "true")
|
|
||||||
{
|
|
||||||
$('#password').focus();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$('#username').focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#user-picture").on("change", function(e)
|
$("#user-picture").on("change", function(e)
|
||||||
{
|
{
|
||||||
$("#user-picture-label").removeClass("d-none");
|
$("#user-picture-label").removeClass("d-none");
|
||||||
@@ -148,5 +139,25 @@ $("#delete-current-user-picture-button").on("click", function(e)
|
|||||||
$("#user-picture-label-none").removeClass("d-none");
|
$("#user-picture-label-none").removeClass("d-none");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#change_password").click(function()
|
||||||
|
{
|
||||||
|
$("#password").attr("disabled", !this.checked);
|
||||||
|
$("#password_confirm").attr("disabled", !this.checked);
|
||||||
|
|
||||||
|
setTimeout(function()
|
||||||
|
{
|
||||||
|
$("#password").focus();
|
||||||
|
}, 200);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (GetUriParam("changepw") === "true")
|
||||||
|
{
|
||||||
|
$("#change_password").click();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$('#username').focus();
|
||||||
|
}
|
||||||
|
|
||||||
Grocy.Components.UserfieldsForm.Load();
|
Grocy.Components.UserfieldsForm.Load();
|
||||||
Grocy.FrontendHelpers.ValidateForm('user-form');
|
Grocy.FrontendHelpers.ValidateForm('user-form');
|
||||||
|
@@ -35,7 +35,7 @@ class UsersService extends BaseService
|
|||||||
$row->delete();
|
$row->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function EditUser(int $userId, string $username, string $firstName, string $lastName, string $password, string $pictureFileName = null)
|
public function EditUser(int $userId, string $username, string $firstName, string $lastName, ?string $password, string $pictureFileName = null)
|
||||||
{
|
{
|
||||||
if (!$this->UserExists($userId))
|
if (!$this->UserExists($userId))
|
||||||
{
|
{
|
||||||
@@ -43,13 +43,26 @@ class UsersService extends BaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->getDatabase()->users($userId);
|
$user = $this->getDatabase()->users($userId);
|
||||||
$user->update([
|
|
||||||
'username' => $username,
|
if ($password == null || empty($password))
|
||||||
'first_name' => $firstName,
|
{
|
||||||
'last_name' => $lastName,
|
$user->update([
|
||||||
'password' => password_hash($password, PASSWORD_DEFAULT),
|
'username' => $username,
|
||||||
'picture_file_name' => $pictureFileName
|
'first_name' => $firstName,
|
||||||
]);
|
'last_name' => $lastName,
|
||||||
|
'picture_file_name' => $pictureFileName
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$user->update([
|
||||||
|
'username' => $username,
|
||||||
|
'first_name' => $firstName,
|
||||||
|
'last_name' => $lastName,
|
||||||
|
'password' => password_hash($password, PASSWORD_DEFAULT),
|
||||||
|
'picture_file_name' => $pictureFileName
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetUserSetting($userId, $settingKey)
|
public function GetUserSetting($userId, $settingKey)
|
||||||
|
@@ -66,13 +66,32 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if(!defined('GROCY_EXTERNALLY_MANAGED_AUTHENTICATION'))
|
@if(!defined('GROCY_EXTERNALLY_MANAGED_AUTHENTICATION'))
|
||||||
|
@if($mode == 'edit')
|
||||||
|
<div class="form-group mb-1">
|
||||||
|
<div class="custom-control custom-checkbox">
|
||||||
|
<input class="form-check-input custom-control-input"
|
||||||
|
type="checkbox"
|
||||||
|
id="change_password"
|
||||||
|
name="change_password"
|
||||||
|
value="1">
|
||||||
|
<label class="form-check-label custom-control-label"
|
||||||
|
for="change_password">{{ $__t('Change password') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="password">{{ $__t('Password') }}</label>
|
<label for="password">{{ $__t('Password') }}</label>
|
||||||
<input type="password"
|
<input type="password"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
required
|
required
|
||||||
id="password"
|
id="password"
|
||||||
name="password">
|
name="password"
|
||||||
|
@if($mode=='edit'
|
||||||
|
)
|
||||||
|
disabled
|
||||||
|
@endif>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -81,7 +100,11 @@
|
|||||||
class="form-control"
|
class="form-control"
|
||||||
required
|
required
|
||||||
id="password_confirm"
|
id="password_confirm"
|
||||||
name="password_confirm">
|
name="password_confirm"
|
||||||
|
@if($mode=='edit'
|
||||||
|
)
|
||||||
|
disabled
|
||||||
|
@endif>
|
||||||
<div class="invalid-feedback">{{ $__t('Passwords do not match') }}</div>
|
<div class="invalid-feedback">{{ $__t('Passwords do not match') }}</div>
|
||||||
</div>
|
</div>
|
||||||
@else
|
@else
|
||||||
|
Reference in New Issue
Block a user