diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2020-01-28 20:48:18 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2020-01-29 15:57:59 +0100 |
commit | 34426a481faa5ff76317295305d7c6fad2c8534f (patch) | |
tree | a507b26f91562c0d5b9a0fee3ff6a9a6355b29ae /apps/settings/lib | |
parent | edd37368fd101439d7c9a9683aeb39b3844945c3 (diff) | |
download | nextcloud-server-34426a481faa5ff76317295305d7c6fad2c8534f.tar.gz nextcloud-server-34426a481faa5ff76317295305d7c6fad2c8534f.zip |
Move can create token logic
It makes sense to have this in the actual authtoken settings. As well.
This is where it is used.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/settings/lib')
-rw-r--r-- | apps/settings/lib/Settings/Personal/Security.php | 13 | ||||
-rw-r--r-- | apps/settings/lib/Settings/Personal/Security/Authtokens.php | 12 |
2 files changed, 13 insertions, 12 deletions
diff --git a/apps/settings/lib/Settings/Personal/Security.php b/apps/settings/lib/Settings/Personal/Security.php index 5734eaa5ca3..192b082d6b1 100644 --- a/apps/settings/lib/Settings/Personal/Security.php +++ b/apps/settings/lib/Settings/Personal/Security.php @@ -50,9 +50,6 @@ use OCP\Settings\ISettings; class Security implements ISettings { - /** @var IInitialStateService */ - private $initialStateService; - /** @var IUserManager */ private $userManager; @@ -68,13 +65,11 @@ class Security implements ISettings { /** @var IConfig */ private $config; - public function __construct(IInitialStateService $initialStateService, - IUserManager $userManager, + public function __construct(IUserManager $userManager, ProviderLoader $providerLoader, IUserSession $userSession, IConfig $config, ?string $UserId) { - $this->initialStateService = $initialStateService; $this->userManager = $userManager; $this->providerLoader = $providerLoader; $this->userSession = $userSession; @@ -89,12 +84,6 @@ class Security implements ISettings { $passwordChangeSupported = $user->canChangePassword(); } - $this->initialStateService->provideInitialState( - 'settings', - 'can_create_app_token', - $this->userSession->getImpersonatingUserID() === null - ); - return new TemplateResponse('settings', 'settings/personal/security', [ 'passwordChangeSupported' => $passwordChangeSupported, 'twoFactorProviderData' => $this->getTwoFactorProviderData(), diff --git a/apps/settings/lib/Settings/Personal/Security/Authtokens.php b/apps/settings/lib/Settings/Personal/Security/Authtokens.php index 04825069920..1944670b2ea 100644 --- a/apps/settings/lib/Settings/Personal/Security/Authtokens.php +++ b/apps/settings/lib/Settings/Personal/Security/Authtokens.php @@ -27,6 +27,7 @@ declare(strict_types=1); namespace OCA\Settings\Personal\Security; +use OCP\IUserSession; use function array_map; use OC\Authentication\Exceptions\InvalidTokenException; use OC\Authentication\Token\INamedToken; @@ -52,14 +53,19 @@ class Authtokens implements ISettings { /** @var string|null */ private $uid; + /** @var IUserSession */ + private $userSession; + public function __construct(IAuthTokenProvider $tokenProvider, ISession $session, + IUserSession $userSession, IInitialStateService $initialStateService, ?string $UserId) { $this->tokenProvider = $tokenProvider; $this->session = $session; $this->initialStateService = $initialStateService; $this->uid = $UserId; + $this->userSession = $userSession; } public function getForm(): TemplateResponse { @@ -69,6 +75,12 @@ class Authtokens implements ISettings { $this->getAppTokens() ); + $this->initialStateService->provideInitialState( + 'settings', + 'can_create_app_token', + $this->userSession->getImpersonatingUserID() === null + ); + return new TemplateResponse('settings', 'settings/personal/security/authtokens'); } |