* @return TemplateResponse
*/
public function resetform($token, $userId) {
+ if ($this->config->getSystemValue('lost_password_link', '') !== '') {
+ return new TemplateResponse('core', 'error', [
+ 'errors' => [['error' => $this->l10n->t('Password reset is disabled')]]
+ ],
+ 'guest'
+ );
+ }
+
try {
$this->checkPasswordResetToken($token, $userId);
} catch (\Exception $e) {
* @return JSONResponse
*/
public function email($user){
+ if ($this->config->getSystemValue('lost_password_link', '') !== '') {
+ return new JSONResponse($this->error($this->l10n->t('Password reset is disabled')));
+ }
+
// FIXME: use HTTP error codes
try {
$this->sendEmail($user);
* @return array
*/
public function setPassword($token, $userId, $password, $proceed) {
+ if ($this->config->getSystemValue('lost_password_link', '') !== '') {
+ return $this->error($this->l10n->t('Password reset is disabled'));
+ }
+
if ($this->encryptionManager->isEnabled() && !$proceed) {
return $this->error('', array('encryption' => true));
}
if (!$('#user').val().length){
$('#submit').trigger('click');
} else {
- if (OC.config.lost_password_link) {
+ if (OC.config.lost_password_link === 'disabled') {
+ return;
+ } else if (OC.config.lost_password_link) {
window.location = OC.config.lost_password_link;
} else {
$.post(
->willReturn('ExistingUser');
$this->config = $this->createMock(IConfig::class);
- $this->config->method('getSystemValue')
- ->with('secret', null)
- ->willReturn('SECRET');
+ $this->config->expects($this->any())
+ ->method('getSystemValue')
+ ->willReturnMap([
+ ['secret', null, 'SECRET'],
+ ['secret', '', 'SECRET'],
+ ['lost_password_link', '', ''],
+ ]);
$this->l10n = $this->createMock(IL10N::class);
$this->l10n
->expects($this->any())
->method('send')
->with($message);
- $this->config->method('getSystemValue')
- ->with('secret', '')
- ->willReturn('SECRET');
-
$this->crypto->method('encrypt')
->with(
$this->equalTo('12348:ThisIsMaybeANotSoSecretToken!'),
->method('send')
->with($message);
- $this->config->method('getSystemValue')
- ->with('secret', '')
- ->willReturn('SECRET');
-
$this->crypto->method('encrypt')
->with(
$this->equalTo('12348:ThisIsMaybeANotSoSecretToken!'),
->with($message)
->will($this->throwException(new \Exception()));
- $this->config->method('getSystemValue')
- ->with('secret', '')
- ->willReturn('SECRET');
-
$this->crypto->method('encrypt')
->with(
$this->equalTo('12348:ThisIsMaybeANotSoSecretToken!'),