|
|
|
@ -51,7 +51,7 @@ use OCP\Mail\IMailer; |
|
|
|
use OCP\IAvatarManager; |
|
|
|
use OCP\Security\ICrypto; |
|
|
|
use OCP\Security\ISecureRandom; |
|
|
|
use OC\AppFramework\Utility\TimeFactory; |
|
|
|
use OCP\AppFramework\Utility\ITimeFactory; |
|
|
|
|
|
|
|
/** |
|
|
|
* @package OC\Settings\Controller |
|
|
|
@ -89,7 +89,7 @@ class UsersController extends Controller { |
|
|
|
private $accountManager; |
|
|
|
/** @var ISecureRandom */ |
|
|
|
private $secureRandom; |
|
|
|
/** @var TimeFactory */ |
|
|
|
/** @var ITimeFactory */ |
|
|
|
private $timeFactory; |
|
|
|
/** @var ICrypto */ |
|
|
|
private $crypto; |
|
|
|
@ -113,7 +113,7 @@ class UsersController extends Controller { |
|
|
|
* @param IAvatarManager $avatarManager |
|
|
|
* @param AccountManager $accountManager |
|
|
|
* @param ISecureRandom $secureRandom |
|
|
|
* @param TimeFactory $timeFactory |
|
|
|
* @param ITimeFactory $timeFactory |
|
|
|
* @param ICrypto $crypto |
|
|
|
*/ |
|
|
|
public function __construct($appName, |
|
|
|
@ -133,7 +133,7 @@ class UsersController extends Controller { |
|
|
|
IAvatarManager $avatarManager, |
|
|
|
AccountManager $accountManager, |
|
|
|
ISecureRandom $secureRandom, |
|
|
|
TimeFactory $timeFactory, |
|
|
|
ITimeFactory $timeFactory, |
|
|
|
ICrypto $crypto) { |
|
|
|
parent::__construct($appName, $request); |
|
|
|
$this->userManager = $userManager; |
|
|
|
@ -411,19 +411,22 @@ class UsersController extends Controller { |
|
|
|
if($email !== '') { |
|
|
|
$user->setEMailAddress($email); |
|
|
|
|
|
|
|
$token = $this->secureRandom->generate( |
|
|
|
21, |
|
|
|
ISecureRandom::CHAR_DIGITS. |
|
|
|
ISecureRandom::CHAR_LOWER. |
|
|
|
ISecureRandom::CHAR_UPPER |
|
|
|
); |
|
|
|
$tokenValue = $this->timeFactory->getTime() .':'. $token; |
|
|
|
$mailAddress = !is_null($user->getEMailAddress()) ? $user->getEMailAddress() : ''; |
|
|
|
$encryptedValue = $this->crypto->encrypt($tokenValue, $mailAddress.$this->config->getSystemValue('secret')); |
|
|
|
$this->config->setUserValue($username, 'core', 'lostpassword', $encryptedValue); |
|
|
|
|
|
|
|
$link = $this->urlGenerator->linkToRouteAbsolute('core.lost.resetform', array('userId' => $username, 'token' => $token)); |
|
|
|
|
|
|
|
if ($this->config->getAppValue('core', 'umgmt_send_passwordlink', 'false') === 'true') { |
|
|
|
$token = $this->secureRandom->generate( |
|
|
|
21, |
|
|
|
ISecureRandom::CHAR_DIGITS . |
|
|
|
ISecureRandom::CHAR_LOWER . |
|
|
|
ISecureRandom::CHAR_UPPER |
|
|
|
); |
|
|
|
$tokenValue = $this->timeFactory->getTime() . ':' . $token; |
|
|
|
$mailAddress = !is_null($user->getEMailAddress()) ? $user->getEMailAddress() : ''; |
|
|
|
$encryptedValue = $this->crypto->encrypt($tokenValue, $mailAddress . $this->config->getSystemValue('secret')); |
|
|
|
$this->config->setUserValue($username, 'core', 'lostpassword', $encryptedValue); |
|
|
|
|
|
|
|
$link = $this->urlGenerator->linkToRouteAbsolute('core.lost.resetform', array('userId' => $username, 'token' => $token)); |
|
|
|
} else { |
|
|
|
$link = $this->urlGenerator->getAbsoluteURL('/'); |
|
|
|
} |
|
|
|
|
|
|
|
// data for the mail template
|
|
|
|
$mailData = array( |
|
|
|
|