mirror of
https://github.com/getgrav/grav.git
synced 2026-07-05 23:28:32 +02:00
Fix https://github.com/getgrav/grav-plugin-admin/issues/682 saving a user when it's not yet created
This commit is contained in:
@@ -124,14 +124,21 @@ class User extends Data
|
||||
public function save()
|
||||
{
|
||||
$file = $this->file();
|
||||
|
||||
if ($file) {
|
||||
$username = $this->get('username');
|
||||
|
||||
if (!$file->filename()) {
|
||||
$locator = Grav::instance()['locator'];
|
||||
$file->filename($locator->findResource('account://') . DS . strtolower($username) . YAML_EXT);
|
||||
}
|
||||
|
||||
// if plain text password, hash it and remove plain text
|
||||
if ($this->password) {
|
||||
$this->hashed_password = Authentication::create($this->password);
|
||||
unset($this->password);
|
||||
}
|
||||
|
||||
$username = $this->get('username');
|
||||
unset($this->username);
|
||||
$file->save($this->items);
|
||||
$this->set('username', $username);
|
||||
|
||||
Reference in New Issue
Block a user