2016-04-11 13:08:00 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2017-02-07 03:25:39 +03:00
|
|
|
* @copyright Copyright (c) 2017, Sandro Lutz <sandro.lutz@temparus.ch>
|
2016-09-19 16:33:30 +03:00
|
|
|
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
|
2016-07-21 18:07:57 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
|
|
|
* @author Daniel Kesselberg <mail@danielkesselberg.de>
|
2016-07-21 18:07:57 +03:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2020-04-29 12:57:22 +03:00
|
|
|
* @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Julius Härtl <jus@bitgrid.net>
|
2016-05-26 20:56:05 +03:00
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Michael Weimann <mail@michael-weimann.eu>
|
|
|
|
* @author Rayn0r <andrew@ilpss8.myfirewall.org>
|
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2016-04-11 13:08:00 +03:00
|
|
|
*
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2016-04-11 13:08:00 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OC\Core\Controller;
|
|
|
|
|
2019-11-12 23:48:56 +03:00
|
|
|
use OC\AppFramework\Http\Request;
|
2019-05-03 16:09:19 +03:00
|
|
|
use OC\Authentication\Login\Chain;
|
|
|
|
use OC\Authentication\Login\LoginData;
|
2020-02-09 22:06:08 +03:00
|
|
|
use OC\Authentication\WebAuthn\Manager as WebAuthnManager;
|
2018-01-13 23:12:22 +03:00
|
|
|
use OC\Security\Bruteforce\Throttler;
|
2016-04-25 15:10:55 +03:00
|
|
|
use OC\User\Session;
|
|
|
|
use OC_App;
|
|
|
|
use OC_Util;
|
2016-04-11 13:08:00 +03:00
|
|
|
use OCP\AppFramework\Controller;
|
2016-09-19 16:33:30 +03:00
|
|
|
use OCP\AppFramework\Http;
|
|
|
|
use OCP\AppFramework\Http\DataResponse;
|
2016-04-11 13:08:00 +03:00
|
|
|
use OCP\AppFramework\Http\RedirectResponse;
|
|
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
2017-09-02 17:19:02 +03:00
|
|
|
use OCP\Defaults;
|
2016-04-11 13:08:00 +03:00
|
|
|
use OCP\IConfig;
|
2019-05-21 09:58:35 +03:00
|
|
|
use OCP\IInitialStateService;
|
2017-01-12 14:38:45 +03:00
|
|
|
use OCP\ILogger;
|
2016-04-11 13:08:00 +03:00
|
|
|
use OCP\IRequest;
|
|
|
|
use OCP\ISession;
|
2016-04-18 13:14:07 +03:00
|
|
|
use OCP\IURLGenerator;
|
2019-05-21 09:58:35 +03:00
|
|
|
use OCP\IUser;
|
2016-04-11 13:08:00 +03:00
|
|
|
use OCP\IUserManager;
|
2016-09-29 17:38:29 +03:00
|
|
|
use OCP\IUserSession;
|
2017-09-02 17:19:02 +03:00
|
|
|
use OCP\Util;
|
2016-04-11 13:08:00 +03:00
|
|
|
|
|
|
|
class LoginController extends Controller {
|
2020-04-10 17:54:27 +03:00
|
|
|
public const LOGIN_MSG_INVALIDPASSWORD = 'invalidpassword';
|
|
|
|
public const LOGIN_MSG_USERDISABLED = 'userdisabled';
|
2018-07-21 14:05:13 +03:00
|
|
|
|
2016-04-11 13:08:00 +03:00
|
|
|
/** @var IUserManager */
|
|
|
|
private $userManager;
|
|
|
|
/** @var IConfig */
|
|
|
|
private $config;
|
|
|
|
/** @var ISession */
|
|
|
|
private $session;
|
2016-09-29 17:38:29 +03:00
|
|
|
/** @var IUserSession|Session */
|
2016-04-11 13:08:00 +03:00
|
|
|
private $userSession;
|
2016-04-18 13:14:07 +03:00
|
|
|
/** @var IURLGenerator */
|
|
|
|
private $urlGenerator;
|
2017-01-12 14:38:45 +03:00
|
|
|
/** @var ILogger */
|
|
|
|
private $logger;
|
2017-09-02 17:19:02 +03:00
|
|
|
/** @var Defaults */
|
|
|
|
private $defaults;
|
2018-01-13 23:12:22 +03:00
|
|
|
/** @var Throttler */
|
|
|
|
private $throttler;
|
2019-05-03 16:09:19 +03:00
|
|
|
/** @var Chain */
|
|
|
|
private $loginChain;
|
2019-05-21 09:58:35 +03:00
|
|
|
/** @var IInitialStateService */
|
|
|
|
private $initialStateService;
|
2020-02-09 22:06:08 +03:00
|
|
|
/** @var WebAuthnManager */
|
|
|
|
private $webAuthnManager;
|
2016-05-11 12:23:25 +03:00
|
|
|
|
2019-05-03 16:09:19 +03:00
|
|
|
public function __construct(?string $appName,
|
2017-09-02 17:19:02 +03:00
|
|
|
IRequest $request,
|
|
|
|
IUserManager $userManager,
|
|
|
|
IConfig $config,
|
|
|
|
ISession $session,
|
|
|
|
IUserSession $userSession,
|
|
|
|
IURLGenerator $urlGenerator,
|
|
|
|
ILogger $logger,
|
2018-01-13 23:12:22 +03:00
|
|
|
Defaults $defaults,
|
2019-05-03 16:09:19 +03:00
|
|
|
Throttler $throttler,
|
2019-05-21 09:58:35 +03:00
|
|
|
Chain $loginChain,
|
2020-02-09 22:06:08 +03:00
|
|
|
IInitialStateService $initialStateService,
|
|
|
|
WebAuthnManager $webAuthnManager) {
|
2016-04-11 13:08:00 +03:00
|
|
|
parent::__construct($appName, $request);
|
|
|
|
$this->userManager = $userManager;
|
|
|
|
$this->config = $config;
|
|
|
|
$this->session = $session;
|
|
|
|
$this->userSession = $userSession;
|
2016-04-18 13:14:07 +03:00
|
|
|
$this->urlGenerator = $urlGenerator;
|
2017-01-12 14:38:45 +03:00
|
|
|
$this->logger = $logger;
|
2017-09-02 17:19:02 +03:00
|
|
|
$this->defaults = $defaults;
|
2018-01-13 23:12:22 +03:00
|
|
|
$this->throttler = $throttler;
|
2019-05-03 16:09:19 +03:00
|
|
|
$this->loginChain = $loginChain;
|
2019-05-21 09:58:35 +03:00
|
|
|
$this->initialStateService = $initialStateService;
|
2020-02-09 22:06:08 +03:00
|
|
|
$this->webAuthnManager = $webAuthnManager;
|
2016-04-18 13:14:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @NoAdminRequired
|
|
|
|
* @UseSession
|
|
|
|
*
|
|
|
|
* @return RedirectResponse
|
|
|
|
*/
|
|
|
|
public function logout() {
|
2017-02-02 23:56:44 +03:00
|
|
|
$loginToken = $this->request->getCookie('nc_token');
|
2016-04-18 13:14:07 +03:00
|
|
|
if (!is_null($loginToken)) {
|
|
|
|
$this->config->deleteUserValue($this->userSession->getUser()->getUID(), 'login_token', $loginToken);
|
|
|
|
}
|
|
|
|
$this->userSession->logout();
|
|
|
|
|
2018-08-27 13:18:14 +03:00
|
|
|
$response = new RedirectResponse($this->urlGenerator->linkToRouteAbsolute(
|
|
|
|
'core.login.showLoginForm',
|
|
|
|
['clear' => true] // this param the the code in login.js may be removed when the "Clear-Site-Data" is working in the browsers
|
|
|
|
));
|
2018-11-22 01:21:28 +03:00
|
|
|
|
|
|
|
$this->session->set('clearingExecutionContexts', '1');
|
|
|
|
$this->session->close();
|
2019-11-12 23:48:56 +03:00
|
|
|
|
|
|
|
if (!$this->request->isUserAgent([Request::USER_AGENT_CHROME, Request::USER_AGENT_ANDROID_MOBILE_CHROME])) {
|
|
|
|
$response->addHeader('Clear-Site-Data', '"cache", "storage"');
|
|
|
|
}
|
|
|
|
|
2017-06-20 20:46:10 +03:00
|
|
|
return $response;
|
2016-04-11 13:08:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @PublicPage
|
|
|
|
* @NoCSRFRequired
|
|
|
|
* @UseSession
|
|
|
|
*
|
|
|
|
* @param string $user
|
|
|
|
* @param string $redirect_url
|
|
|
|
*
|
2016-05-06 17:31:40 +03:00
|
|
|
* @return TemplateResponse|RedirectResponse
|
2016-04-11 13:08:00 +03:00
|
|
|
*/
|
2018-04-11 01:20:15 +03:00
|
|
|
public function showLoginForm(string $user = null, string $redirect_url = null): Http\Response {
|
2016-04-25 15:10:55 +03:00
|
|
|
if ($this->userSession->isLoggedIn()) {
|
|
|
|
return new RedirectResponse(OC_Util::getDefaultPageUrl());
|
2016-04-11 13:08:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
$loginMessages = $this->session->get('loginMessages');
|
2016-04-25 15:10:55 +03:00
|
|
|
if (is_array($loginMessages)) {
|
2021-01-12 12:15:48 +03:00
|
|
|
[$errors, $messages] = $loginMessages;
|
2019-05-21 09:58:35 +03:00
|
|
|
$this->initialStateService->provideInitialState('core', 'loginMessages', $messages);
|
|
|
|
$this->initialStateService->provideInitialState('core', 'loginErrors', $errors);
|
2016-04-11 13:08:00 +03:00
|
|
|
}
|
|
|
|
$this->session->remove('loginMessages');
|
|
|
|
|
2018-01-13 23:12:22 +03:00
|
|
|
if ($user !== null && $user !== '') {
|
2019-05-21 09:58:35 +03:00
|
|
|
$this->initialStateService->provideInitialState('core', 'loginUsername', $user);
|
2016-04-11 13:08:00 +03:00
|
|
|
} else {
|
2019-05-21 09:58:35 +03:00
|
|
|
$this->initialStateService->provideInitialState('core', 'loginUsername', '');
|
2016-04-11 13:08:00 +03:00
|
|
|
}
|
2018-10-28 08:28:54 +03:00
|
|
|
|
2019-05-21 09:58:35 +03:00
|
|
|
$this->initialStateService->provideInitialState(
|
|
|
|
'core',
|
|
|
|
'loginAutocomplete',
|
|
|
|
$this->config->getSystemValue('login_form_autocomplete', true) === true
|
|
|
|
);
|
2018-10-28 08:28:54 +03:00
|
|
|
|
2016-04-11 13:08:00 +03:00
|
|
|
if (!empty($redirect_url)) {
|
2021-01-15 11:29:54 +03:00
|
|
|
[$url, ] = explode('?', $redirect_url);
|
|
|
|
if ($url !== $this->urlGenerator->linkToRoute('core.login.logout')) {
|
|
|
|
$this->initialStateService->provideInitialState('core', 'loginRedirectUrl', $redirect_url);
|
|
|
|
}
|
2016-04-11 13:08:00 +03:00
|
|
|
}
|
|
|
|
|
2019-05-21 09:58:35 +03:00
|
|
|
$this->initialStateService->provideInitialState(
|
|
|
|
'core',
|
|
|
|
'loginThrottleDelay',
|
|
|
|
$this->throttler->getDelay($this->request->getRemoteAddress())
|
|
|
|
);
|
2016-04-11 13:08:00 +03:00
|
|
|
|
2019-05-21 09:58:35 +03:00
|
|
|
$this->setPasswordResetInitialState($user);
|
2018-01-13 23:12:22 +03:00
|
|
|
|
2020-02-09 22:06:08 +03:00
|
|
|
$this->initialStateService->provideInitialState('core', 'webauthn-available', $this->webAuthnManager->isWebAuthnAvailable());
|
|
|
|
|
2021-03-03 13:18:33 +03:00
|
|
|
$this->initialStateService->provideInitialState('core', 'hideLoginForm', $this->config->getSystemValueBool('hide_login_form', false));
|
|
|
|
|
2017-09-02 17:19:02 +03:00
|
|
|
// OpenGraph Support: http://ogp.me/
|
2017-09-06 17:24:49 +03:00
|
|
|
Util::addHeader('meta', ['property' => 'og:title', 'content' => Util::sanitizeHTML($this->defaults->getName())]);
|
|
|
|
Util::addHeader('meta', ['property' => 'og:description', 'content' => Util::sanitizeHTML($this->defaults->getSlogan())]);
|
|
|
|
Util::addHeader('meta', ['property' => 'og:site_name', 'content' => Util::sanitizeHTML($this->defaults->getName())]);
|
|
|
|
Util::addHeader('meta', ['property' => 'og:url', 'content' => $this->urlGenerator->getAbsoluteURL('/')]);
|
|
|
|
Util::addHeader('meta', ['property' => 'og:type', 'content' => 'website']);
|
2018-08-28 16:58:27 +03:00
|
|
|
Util::addHeader('meta', ['property' => 'og:image', 'content' => $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'favicon-touch.png'))]);
|
2017-09-02 17:19:02 +03:00
|
|
|
|
2019-05-21 09:58:35 +03:00
|
|
|
$parameters = [
|
|
|
|
'alt_login' => OC_App::getAlternativeLogIns(),
|
|
|
|
];
|
2021-04-16 12:03:12 +03:00
|
|
|
|
|
|
|
$this->initialStateService->provideInitialState('core', 'countAlternativeLogins', count($parameters['alt_login']));
|
|
|
|
|
2016-04-11 13:08:00 +03:00
|
|
|
return new TemplateResponse(
|
2016-04-25 15:10:55 +03:00
|
|
|
$this->appName, 'login', $parameters, 'guest'
|
2016-04-11 13:08:00 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-07-21 14:05:13 +03:00
|
|
|
/**
|
2019-05-21 09:58:35 +03:00
|
|
|
* Sets the password reset state
|
|
|
|
*
|
|
|
|
* @param string $username
|
|
|
|
*/
|
|
|
|
private function setPasswordResetInitialState(?string $username): void {
|
|
|
|
if ($username !== null && $username !== '') {
|
|
|
|
$user = $this->userManager->get($username);
|
|
|
|
} else {
|
|
|
|
$user = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$passwordLink = $this->config->getSystemValue('lost_password_link', '');
|
|
|
|
|
|
|
|
$this->initialStateService->provideInitialState(
|
|
|
|
'core',
|
|
|
|
'loginResetPasswordLink',
|
|
|
|
$passwordLink
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->initialStateService->provideInitialState(
|
|
|
|
'core',
|
|
|
|
'loginCanResetPassword',
|
|
|
|
$this->canResetPassword($passwordLink, $user)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string|null $passwordLink
|
|
|
|
* @param IUser|null $user
|
2018-07-21 14:05:13 +03:00
|
|
|
*
|
|
|
|
* Users may not change their passwords if:
|
|
|
|
* - The account is disabled
|
|
|
|
* - The backend doesn't support password resets
|
|
|
|
* - The password reset function is disabled
|
|
|
|
*
|
2019-05-21 09:58:35 +03:00
|
|
|
* @return bool
|
2018-07-21 14:05:13 +03:00
|
|
|
*/
|
2019-05-21 09:58:35 +03:00
|
|
|
private function canResetPassword(?string $passwordLink, ?IUser $user): bool {
|
|
|
|
if ($passwordLink === 'disabled') {
|
|
|
|
return false;
|
2018-07-21 14:05:13 +03:00
|
|
|
}
|
|
|
|
|
2019-05-21 09:58:35 +03:00
|
|
|
if (!$passwordLink && $user !== null) {
|
|
|
|
return $user->canChangePassword();
|
|
|
|
}
|
2018-07-21 14:05:13 +03:00
|
|
|
|
2019-05-21 09:58:35 +03:00
|
|
|
if ($user !== null && $user->isEnabled() === false) {
|
|
|
|
return false;
|
2018-07-21 14:05:13 +03:00
|
|
|
}
|
|
|
|
|
2019-05-21 09:58:35 +03:00
|
|
|
return true;
|
2018-07-21 14:05:13 +03:00
|
|
|
}
|
|
|
|
|
2019-05-03 16:09:19 +03:00
|
|
|
private function generateRedirect(?string $redirectUrl): RedirectResponse {
|
|
|
|
if ($redirectUrl !== null && $this->userSession->isLoggedIn()) {
|
2020-04-10 09:50:15 +03:00
|
|
|
$location = $this->urlGenerator->getAbsoluteURL($redirectUrl);
|
2016-08-09 20:01:50 +03:00
|
|
|
// Deny the redirect if the URL contains a @
|
|
|
|
// This prevents unvalidated redirects like ?redirect_url=:user@domain.com
|
|
|
|
if (strpos($location, '@') === false) {
|
|
|
|
return new RedirectResponse($location);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new RedirectResponse(OC_Util::getDefaultPageUrl());
|
|
|
|
}
|
|
|
|
|
2016-04-25 15:10:55 +03:00
|
|
|
/**
|
|
|
|
* @PublicPage
|
|
|
|
* @UseSession
|
2016-08-09 20:01:50 +03:00
|
|
|
* @NoCSRFRequired
|
2017-04-13 23:50:44 +03:00
|
|
|
* @BruteForceProtection(action=login)
|
2016-04-25 15:10:55 +03:00
|
|
|
*
|
|
|
|
* @param string $user
|
|
|
|
* @param string $password
|
|
|
|
* @param string $redirect_url
|
2016-12-08 12:45:24 +03:00
|
|
|
* @param string $timezone
|
|
|
|
* @param string $timezone_offset
|
2019-05-21 09:58:35 +03:00
|
|
|
*
|
2016-04-25 15:10:55 +03:00
|
|
|
* @return RedirectResponse
|
|
|
|
*/
|
2019-05-03 16:09:19 +03:00
|
|
|
public function tryLogin(string $user,
|
|
|
|
string $password,
|
|
|
|
string $redirect_url = null,
|
|
|
|
string $timezone = '',
|
|
|
|
string $timezone_offset = ''): RedirectResponse {
|
2016-08-09 20:01:50 +03:00
|
|
|
// If the user is already logged in and the CSRF check does not pass then
|
|
|
|
// simply redirect the user to the correct page as required. This is the
|
|
|
|
// case when an user has already logged-in, in another tab.
|
2019-05-21 09:58:35 +03:00
|
|
|
if (!$this->request->passesCSRFCheck()) {
|
2016-08-09 20:01:50 +03:00
|
|
|
return $this->generateRedirect($redirect_url);
|
|
|
|
}
|
|
|
|
|
2019-05-03 16:09:19 +03:00
|
|
|
$data = new LoginData(
|
|
|
|
$this->request,
|
2019-11-27 16:54:45 +03:00
|
|
|
trim($user),
|
2019-05-03 16:09:19 +03:00
|
|
|
$password,
|
|
|
|
$redirect_url,
|
|
|
|
$timezone,
|
|
|
|
$timezone_offset
|
|
|
|
);
|
|
|
|
$result = $this->loginChain->process($data);
|
|
|
|
if (!$result->isSuccess()) {
|
|
|
|
return $this->createLoginFailedResponse(
|
|
|
|
$data->getUsername(),
|
|
|
|
$user,
|
|
|
|
$redirect_url,
|
|
|
|
$result->getErrorMessage()
|
|
|
|
);
|
2016-05-11 12:23:25 +03:00
|
|
|
}
|
|
|
|
|
2019-05-03 16:09:19 +03:00
|
|
|
if ($result->getRedirectUrl() !== null) {
|
|
|
|
return new RedirectResponse($result->getRedirectUrl());
|
2016-09-06 22:41:15 +03:00
|
|
|
}
|
2016-08-09 20:01:50 +03:00
|
|
|
return $this->generateRedirect($redirect_url);
|
2016-04-25 15:10:55 +03:00
|
|
|
}
|
|
|
|
|
2018-07-21 14:05:13 +03:00
|
|
|
/**
|
|
|
|
* Creates a login failed response.
|
|
|
|
*
|
|
|
|
* @param string $user
|
|
|
|
* @param string $originalUser
|
|
|
|
* @param string $redirect_url
|
|
|
|
* @param string $loginMessage
|
2019-05-21 09:58:35 +03:00
|
|
|
*
|
2018-07-21 14:05:13 +03:00
|
|
|
* @return RedirectResponse
|
|
|
|
*/
|
|
|
|
private function createLoginFailedResponse(
|
|
|
|
$user, $originalUser, $redirect_url, string $loginMessage) {
|
|
|
|
// Read current user and append if possible we need to
|
|
|
|
// return the unmodified user otherwise we will leak the login name
|
2021-02-01 16:25:56 +03:00
|
|
|
$args = $user !== null ? ['user' => $originalUser, 'direct' => 1] : [];
|
2019-05-03 16:09:19 +03:00
|
|
|
if ($redirect_url !== null) {
|
2018-07-21 14:05:13 +03:00
|
|
|
$args['redirect_url'] = $redirect_url;
|
|
|
|
}
|
|
|
|
$response = new RedirectResponse(
|
|
|
|
$this->urlGenerator->linkToRoute('core.login.showLoginForm', $args)
|
|
|
|
);
|
2018-08-13 16:52:09 +03:00
|
|
|
$response->throttle(['user' => substr($user, 0, 64)]);
|
2018-07-21 14:05:13 +03:00
|
|
|
$this->session->set('loginMessages', [
|
|
|
|
[$loginMessage], []
|
|
|
|
]);
|
|
|
|
return $response;
|
|
|
|
}
|
|
|
|
|
2016-09-19 16:33:30 +03:00
|
|
|
/**
|
|
|
|
* @NoAdminRequired
|
|
|
|
* @UseSession
|
2017-04-13 23:50:44 +03:00
|
|
|
* @BruteForceProtection(action=sudo)
|
2016-09-19 16:33:30 +03:00
|
|
|
*
|
|
|
|
* @param string $password
|
2019-05-21 09:58:35 +03:00
|
|
|
*
|
2016-09-19 16:33:30 +03:00
|
|
|
* @return DataResponse
|
2019-05-21 09:58:35 +03:00
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
2016-09-19 16:33:30 +03:00
|
|
|
*/
|
|
|
|
public function confirmPassword($password) {
|
2016-12-21 11:51:21 +03:00
|
|
|
$loginName = $this->userSession->getLoginName();
|
|
|
|
$loginResult = $this->userManager->checkPassword($loginName, $password);
|
2016-09-19 16:33:30 +03:00
|
|
|
if ($loginResult === false) {
|
2017-04-13 23:50:44 +03:00
|
|
|
$response = new DataResponse([], Http::STATUS_FORBIDDEN);
|
|
|
|
$response->throttle();
|
|
|
|
return $response;
|
2016-09-19 16:33:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
$confirmTimestamp = time();
|
|
|
|
$this->session->set('last-password-confirm', $confirmTimestamp);
|
|
|
|
return new DataResponse(['lastLogin' => $confirmTimestamp], Http::STATUS_OK);
|
|
|
|
}
|
2016-04-11 13:08:00 +03:00
|
|
|
}
|