mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
feat: Allow getting/setting the password hash of a user
Signed-off-by: Christopher Ng <chrng8@gmail.com>
This commit is contained in:
parent
a330f4c9d5
commit
34d97d45cf
3 changed files with 37 additions and 0 deletions
|
|
@ -73,6 +73,14 @@ class LazyUser implements IUser {
|
|||
return $this->getUser()->setPassword($password, $recoveryPassword);
|
||||
}
|
||||
|
||||
public function getPasswordHash(): ?string {
|
||||
return $this->getUser()->getPasswordHash();
|
||||
}
|
||||
|
||||
public function setPasswordHash(string $passwordHash): bool {
|
||||
return $this->getUser()->setPasswordHash($passwordHash);
|
||||
}
|
||||
|
||||
public function getHome() {
|
||||
return $this->getUser()->getHome();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ use OCP\IUser;
|
|||
use OCP\IUserBackend;
|
||||
use OCP\Notification\IManager as INotificationManager;
|
||||
use OCP\User\Backend\IGetHomeBackend;
|
||||
use OCP\User\Backend\IPasswordHashBackend;
|
||||
use OCP\User\Backend\IProvideAvatarBackend;
|
||||
use OCP\User\Backend\IProvideEnabledStateBackend;
|
||||
use OCP\User\Backend\ISetDisplayNameBackend;
|
||||
|
|
@ -319,6 +320,20 @@ class User implements IUser {
|
|||
}
|
||||
}
|
||||
|
||||
public function getPasswordHash(): ?string {
|
||||
if (!($this->backend instanceof IPasswordHashBackend)) {
|
||||
return null;
|
||||
}
|
||||
return $this->backend->getPasswordHash($this->uid);
|
||||
}
|
||||
|
||||
public function setPasswordHash(string $passwordHash): bool {
|
||||
if (!($this->backend instanceof IPasswordHashBackend)) {
|
||||
return false;
|
||||
}
|
||||
return $this->backend->setPasswordHash($this->uid, $passwordHash);
|
||||
}
|
||||
|
||||
/**
|
||||
* get the users home folder to mount
|
||||
*
|
||||
|
|
|
|||
|
|
@ -76,6 +76,20 @@ interface IUser {
|
|||
*/
|
||||
public function setPassword($password, $recoveryPassword = null);
|
||||
|
||||
/**
|
||||
* Get the password hash of the user
|
||||
*
|
||||
* @since 30.0.0
|
||||
*/
|
||||
public function getPasswordHash(): ?string;
|
||||
|
||||
/**
|
||||
* Set the password hash of the user
|
||||
*
|
||||
* @since 30.0.0
|
||||
*/
|
||||
public function setPasswordHash(string $passwordHash): bool;
|
||||
|
||||
/**
|
||||
* get the users home folder to mount
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue