Merge pull request #21288 from lmamane/master
Return correct loginname in credentials
This commit is contained in:
commit
7b8364e001
|
@ -112,7 +112,7 @@ class Store implements IStore {
|
|||
|
||||
if ($trySession && $this->session->exists('login_credentials')) {
|
||||
$creds = json_decode($this->session->get('login_credentials'));
|
||||
return new Credentials($creds->uid, $creds->uid, $creds->password);
|
||||
return new Credentials($creds->uid, $creds->loginName, $creds->password);
|
||||
}
|
||||
|
||||
// If we reach this line, an exception was thrown.
|
||||
|
|
|
@ -565,9 +565,9 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
$dispatcher = $this->query(IEventDispatcher::class);
|
||||
$dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
|
||||
});
|
||||
$userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) {
|
||||
$userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
|
||||
/** @var \OC\User\User $user */
|
||||
\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
|
||||
\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
|
||||
|
||||
/** @var IEventDispatcher $dispatcher */
|
||||
$dispatcher = $this->query(IEventDispatcher::class);
|
||||
|
|
|
@ -80,7 +80,7 @@ use Symfony\Component\EventDispatcher\GenericEvent;
|
|||
* - preUnassignedUserId(string $uid)
|
||||
* - postUnassignedUserId(string $uid)
|
||||
* - preLogin(string $user, string $password)
|
||||
* - postLogin(\OC\User\User $user, string $password)
|
||||
* - postLogin(\OC\User\User $user, string $loginName, string $password, boolean $isTokenLogin)
|
||||
* - preRememberedLogin(string $uid)
|
||||
* - postRememberedLogin(\OC\User\User $user)
|
||||
* - logout()
|
||||
|
@ -400,11 +400,13 @@ class Session implements IUserSession, Emitter {
|
|||
|
||||
$this->dispatcher->dispatchTyped(new PostLoginEvent(
|
||||
$user,
|
||||
$loginDetails['loginName'],
|
||||
$loginDetails['password'],
|
||||
$isToken
|
||||
));
|
||||
$this->manager->emit('\OC\User', 'postLogin', [
|
||||
$user,
|
||||
$loginDetails['loginName'],
|
||||
$loginDetails['password'],
|
||||
$isToken,
|
||||
]);
|
||||
|
|
|
@ -38,6 +38,12 @@ class PostLoginEvent extends Event {
|
|||
/** @var IUser */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @since 20.0.0
|
||||
* @var string
|
||||
*/
|
||||
private $loginName;
|
||||
|
||||
/** @var string */
|
||||
private $password;
|
||||
|
||||
|
@ -47,9 +53,10 @@ class PostLoginEvent extends Event {
|
|||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
public function __construct(IUser $user, string $password, bool $isTokenLogin) {
|
||||
public function __construct(IUser $user, string $loginName, string $password, bool $isTokenLogin) {
|
||||
parent::__construct();
|
||||
$this->user = $user;
|
||||
$this->loginName = $loginName;
|
||||
$this->password = $password;
|
||||
$this->isTokenLogin = $isTokenLogin;
|
||||
}
|
||||
|
@ -61,6 +68,13 @@ class PostLoginEvent extends Event {
|
|||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 20.0.0
|
||||
*/
|
||||
public function getLoginName(): string {
|
||||
return $this->loginName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 18.0.0
|
||||
*/
|
||||
|
|
|
@ -141,7 +141,8 @@ class StoreTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testGetLoginCredentialsInvalidTokenLoginCredentials() {
|
||||
$uid = 'user987';
|
||||
$uid = 'id987';
|
||||
$user = 'user987';
|
||||
$password = '7389374';
|
||||
|
||||
$this->session->expects($this->once())
|
||||
|
@ -158,8 +159,8 @@ class StoreTest extends TestCase {
|
|||
$this->session->expects($this->once())
|
||||
->method('get')
|
||||
->with($this->equalTo('login_credentials'))
|
||||
->willReturn('{"run":true,"uid":"user987","password":"7389374"}');
|
||||
$expected = new Credentials('user987', 'user987', '7389374');
|
||||
->willReturn('{"run":true,"uid":"id987","loginName":"user987","password":"7389374"}');
|
||||
$expected = new Credentials($uid, $user, $password);
|
||||
|
||||
$actual = $this->store->getLoginCredentials();
|
||||
|
||||
|
|
Loading…
Reference in New Issue