public function testLogin() { $name1 = $this->getUser(); $name2 = $this->getUser(); $this->assertFalse($this->backend->userExists($name1)); $this->assertFalse($this->backend->userExists($name2)); $this->backend->createUser($name1, 'pass1'); $this->backend->createUser($name2, 'pass2'); $this->assertTrue($this->backend->userExists($name1)); $this->assertTrue($this->backend->userExists($name2)); $this->assertSame($name1, $this->backend->checkPassword($name1, 'pass1')); $this->assertSame($name2, $this->backend->checkPassword($name2, 'pass2')); $this->assertFalse($this->backend->checkPassword($name1, 'pass2')); $this->assertFalse($this->backend->checkPassword($name2, 'pass1')); $this->assertFalse($this->backend->checkPassword($name1, 'dummy')); $this->assertFalse($this->backend->checkPassword($name2, 'foobar')); $this->backend->setPassword($name1, 'newpass1'); $this->assertFalse($this->backend->checkPassword($name1, 'pass1')); $this->assertSame($name1, $this->backend->checkPassword($name1, 'newpass1')); $this->assertFalse($this->backend->checkPassword($name2, 'newpass1')); }
/** * Set the password of the user * * @param string $password * @param string $recoveryPassword for the encryption app to reset encryption keys * @return bool */ public function setPassword($password, $recoveryPassword) { if ($this->emitter) { $this->emitter->emit('\\OC\\User', 'preSetPassword', array($this, $password, $recoveryPassword)); } if ($this->backend->implementsActions(\OC_USER_BACKEND_SET_PASSWORD)) { $result = $this->backend->setPassword($this->uid, $password); if ($this->emitter) { $this->emitter->emit('\\OC\\User', 'postSetPassword', array($this, $password, $recoveryPassword)); } return !($result === false); } else { return false; } }