aboutsummaryrefslogtreecommitdiffstats
path: root/settings/Controller
diff options
context:
space:
mode:
authortobiasKaminsky <tobias@kaminsky.me>2016-11-23 21:30:15 +0100
committerMorris Jobke <hey@morrisjobke.de>2017-02-15 17:45:20 -0600
commita37f29964f86be5ec51fe33d32e290d3701828b2 (patch)
tree2f11e4aa27c04a0f7f767d105bb081d90dce8276 /settings/Controller
parent3c7755fc662b0fcedad261e2e12755faedb1c567 (diff)
downloadnextcloud-server-a37f29964f86be5ec51fe33d32e290d3701828b2.tar.gz
nextcloud-server-a37f29964f86be5ec51fe33d32e290d3701828b2.zip
add setting for "send password link"
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'settings/Controller')
-rw-r--r--settings/Controller/UsersController.php37
1 files changed, 20 insertions, 17 deletions
diff --git a/settings/Controller/UsersController.php b/settings/Controller/UsersController.php
index f9be5468d35..b81b0f3ee91 100644
--- a/settings/Controller/UsersController.php
+++ b/settings/Controller/UsersController.php
@@ -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(