-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not change the old behavior of user creation
- Loading branch information
1 parent
712327a
commit 97eeafc
Showing
11 changed files
with
102 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
* @author Morris Jobke <[email protected]> | ||
* @author Thomas Müller <[email protected]> | ||
* @author Sujith Haridasan <[email protected]> | ||
* @author Semih Serhat Karakaya <[email protected]> | ||
* | ||
* @copyright Copyright (c) 2018, ownCloud GmbH | ||
* @license AGPL-3.0 | ||
|
@@ -25,6 +26,7 @@ | |
namespace OC\Core\Controller; | ||
|
||
use OC\User\Service\UserSendMailService; | ||
use OC\User\Session; | ||
use \OCP\AppFramework\Controller; | ||
use OCP\AppFramework\Http; | ||
use \OCP\AppFramework\Http\JSONResponse; | ||
|
@@ -38,14 +40,10 @@ | |
use OCP\User\Exceptions\UserTokenExpiredException; | ||
|
||
class UserController extends Controller { | ||
/** | ||
* @var \OCP\IUserManager | ||
*/ | ||
/** @var \OCP\IUserManager */ | ||
protected $userManager; | ||
|
||
/** | ||
* @var \OC_Defaults | ||
*/ | ||
/** @var \OC_Defaults */ | ||
protected $defaults; | ||
|
||
/** @var UserSendMailService */ | ||
|
@@ -60,6 +58,9 @@ class UserController extends Controller { | |
/** @var IL10N */ | ||
private $l10n; | ||
|
||
/** @var Session */ | ||
private $session; | ||
|
||
/** | ||
* UserController constructor. | ||
* | ||
|
@@ -70,15 +71,16 @@ class UserController extends Controller { | |
* @param UserSendMailService $userSendMailService | ||
* @param IURLGenerator $urlGenerator | ||
* @param ILogger $logger | ||
* @param IL10N $l10n | ||
* @param IL10N $l10n, | ||
* @param Session $session | ||
*/ | ||
public function __construct($appName, | ||
IRequest $request, | ||
$userManager, | ||
$defaults, | ||
UserSendMailService $userSendMailService, | ||
IURLGenerator $urlGenerator, ILogger $logger, | ||
IL10N $l10n | ||
IL10N $l10n, Session $session | ||
) { | ||
parent::__construct($appName, $request); | ||
$this->userManager = $userManager; | ||
|
@@ -87,6 +89,7 @@ public function __construct($appName, | |
$this->urlGenerator = $urlGenerator; | ||
$this->logger = $logger; | ||
$this->l10n = $l10n; | ||
$this->session = $session; | ||
} | ||
|
||
/** | ||
|
@@ -147,7 +150,7 @@ public function setPasswordForm($token, $userId) { | |
return new TemplateResponse( | ||
'core', 'error', | ||
[ | ||
"errors" => [["error" => $this->l10n->t($e->getMessage())]] | ||
"errors" => [["error" => $e->getMessage()]] | ||
], 'guest' | ||
); | ||
} | ||
|
@@ -173,7 +176,7 @@ public function resendToken($userId) { | |
$user = $this->userManager->get($userId); | ||
|
||
if ($user === null) { | ||
$this->logger->error('User: ' . $userId . ' does not exist', ['app' => 'core']); | ||
$this->logger->error("Failed to create activation link. User $userId does not exists", ['app' => 'core']); | ||
return new TemplateResponse( | ||
'core', 'error', | ||
[ | ||
|
@@ -231,7 +234,7 @@ public function setPassword($token, $userId, $password) { | |
return new JSONResponse( | ||
[ | ||
'status' => 'error', | ||
'message' => $this->l10n->t('Failed to set password. Please contact the administrator.', [$userId]), | ||
'message' => $this->l10n->t('Failed to set password for %s. Please contact the administrator.', [$userId]), | ||
'type' => 'usererror' | ||
], Http::STATUS_NOT_FOUND | ||
); | ||
|
@@ -245,14 +248,12 @@ public function setPassword($token, $userId, $password) { | |
return new JSONResponse( | ||
[ | ||
'status' => 'error', | ||
'message' => $this->l10n->t('Failed to set password. Please contact your administrator.', [$userId]), | ||
'message' => $this->l10n->t('Failed to set password for %s. Please contact your administrator.', [$userId]), | ||
'type' => 'passwordsetfailed' | ||
], Http::STATUS_FORBIDDEN | ||
); | ||
} | ||
|
||
\OC_Hook::emit('\OC\Core\LostPassword\Controller\LostController', 'post_passwordReset', ['uid' => $userId, 'password' => $password]); | ||
@\OC_User::unsetMagicInCookie(); | ||
$this->session->unsetMagicInCookie(); | ||
} catch (UserTokenException $e) { | ||
$this->logger->logException($e, ['app' => 'core']); | ||
return new JSONResponse( | ||
|
@@ -267,11 +268,11 @@ public function setPassword($token, $userId, $password) { | |
try { | ||
$this->userSendMailService->sendNotificationMail($user); | ||
} catch (EmailSendFailedException $e) { | ||
$this->logger->logException($e, ['app' => 'user_management']); | ||
$this->logger->logException($e, ['app' => 'core']); | ||
return new JSONResponse( | ||
[ | ||
'status' => 'error', | ||
'message' => $this->l10n->t('Failed to send email. Please contact your administrator.'), | ||
'message' => $this->l10n->t('Password set successfully but failed to send email. Please contact your administrator for details.'), | ||
'type' => 'emailsendfailed' | ||
], Http::STATUS_INTERNAL_SERVER_ERROR | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.