Completed
Push — master ( 2c3872...ac3d09 )
by
unknown
62:07 queued 20:56
created
apps/user_ldap/lib/Controller/RenewPasswordController.php 1 patch
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -27,105 +27,105 @@
 block discarded – undo
27 27
 
28 28
 #[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
29 29
 class RenewPasswordController extends Controller {
30
-	public function __construct(
31
-		string $appName,
32
-		IRequest $request,
33
-		private IUserManager $userManager,
34
-		private IConfig $config,
35
-		private IUserConfig $userConfig,
36
-		protected IL10N $l10n,
37
-		private ISession $session,
38
-		private IURLGenerator $urlGenerator,
39
-		private IInitialState $initialState,
40
-	) {
41
-		parent::__construct($appName, $request);
42
-	}
30
+    public function __construct(
31
+        string $appName,
32
+        IRequest $request,
33
+        private IUserManager $userManager,
34
+        private IConfig $config,
35
+        private IUserConfig $userConfig,
36
+        protected IL10N $l10n,
37
+        private ISession $session,
38
+        private IURLGenerator $urlGenerator,
39
+        private IInitialState $initialState,
40
+    ) {
41
+        parent::__construct($appName, $request);
42
+    }
43 43
 
44
-	#[PublicPage]
45
-	#[NoCSRFRequired]
46
-	public function cancel(): RedirectResponse {
47
-		return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
48
-	}
44
+    #[PublicPage]
45
+    #[NoCSRFRequired]
46
+    public function cancel(): RedirectResponse {
47
+        return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
48
+    }
49 49
 
50
-	#[PublicPage]
51
-	#[NoCSRFRequired]
52
-	#[UseSession]
53
-	public function showRenewPasswordForm(string $user): TemplateResponse|RedirectResponse {
54
-		if (!$this->userConfig->getValueBool($user, 'user_ldap', 'needsPasswordReset')) {
55
-			return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
56
-		}
50
+    #[PublicPage]
51
+    #[NoCSRFRequired]
52
+    #[UseSession]
53
+    public function showRenewPasswordForm(string $user): TemplateResponse|RedirectResponse {
54
+        if (!$this->userConfig->getValueBool($user, 'user_ldap', 'needsPasswordReset')) {
55
+            return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
56
+        }
57 57
 
58
-		$renewPasswordMessages = $this->session->get('renewPasswordMessages');
59
-		$errors = [];
60
-		$messages = [];
61
-		if (is_array($renewPasswordMessages)) {
62
-			[$errors, $messages] = $renewPasswordMessages;
63
-		}
64
-		$this->session->remove('renewPasswordMessages');
58
+        $renewPasswordMessages = $this->session->get('renewPasswordMessages');
59
+        $errors = [];
60
+        $messages = [];
61
+        if (is_array($renewPasswordMessages)) {
62
+            [$errors, $messages] = $renewPasswordMessages;
63
+        }
64
+        $this->session->remove('renewPasswordMessages');
65 65
 
66
-		$this->initialState->provideInitialState('renewPasswordParameters',
67
-			[
68
-				'user' => $user,
69
-				'errors' => $errors,
70
-				'messages' => $messages,
71
-				'cancelRenewUrl' => $this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'),
72
-				'tryRenewPasswordUrl' => $this->urlGenerator->linkToRouteAbsolute('user_ldap.renewPassword.tryRenewPassword'),
73
-			],
74
-		);
66
+        $this->initialState->provideInitialState('renewPasswordParameters',
67
+            [
68
+                'user' => $user,
69
+                'errors' => $errors,
70
+                'messages' => $messages,
71
+                'cancelRenewUrl' => $this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'),
72
+                'tryRenewPasswordUrl' => $this->urlGenerator->linkToRouteAbsolute('user_ldap.renewPassword.tryRenewPassword'),
73
+            ],
74
+        );
75 75
 
76
-		Util::addStyle(Application::APP_ID, 'renewPassword');
77
-		Util::addScript(Application::APP_ID, 'renewPassword');
78
-		return new TemplateResponse(
79
-			Application::APP_ID,
80
-			'renewpassword',
81
-			renderAs: 'guest',
82
-		);
83
-	}
76
+        Util::addStyle(Application::APP_ID, 'renewPassword');
77
+        Util::addScript(Application::APP_ID, 'renewPassword');
78
+        return new TemplateResponse(
79
+            Application::APP_ID,
80
+            'renewpassword',
81
+            renderAs: 'guest',
82
+        );
83
+    }
84 84
 
85
-	#[PublicPage]
86
-	#[UseSession]
87
-	public function tryRenewPassword(?string $user, string $oldPassword, ?string $newPassword): RedirectResponse {
88
-		if ($user !== null && !$this->userConfig->getValueBool($user, 'user_ldap', 'needsPasswordReset')) {
89
-			return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
90
-		}
91
-		$args = !is_null($user) ? ['user' => $user] : [];
92
-		$loginResult = $this->userManager->checkPassword($user, $oldPassword);
93
-		if ($loginResult === false) {
94
-			$this->session->set('renewPasswordMessages', [
95
-				['invalidpassword'], []
96
-			]);
97
-			return new RedirectResponse($this->urlGenerator->linkToRoute('user_ldap.renewPassword.showRenewPasswordForm', $args));
98
-		}
85
+    #[PublicPage]
86
+    #[UseSession]
87
+    public function tryRenewPassword(?string $user, string $oldPassword, ?string $newPassword): RedirectResponse {
88
+        if ($user !== null && !$this->userConfig->getValueBool($user, 'user_ldap', 'needsPasswordReset')) {
89
+            return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
90
+        }
91
+        $args = !is_null($user) ? ['user' => $user] : [];
92
+        $loginResult = $this->userManager->checkPassword($user, $oldPassword);
93
+        if ($loginResult === false) {
94
+            $this->session->set('renewPasswordMessages', [
95
+                ['invalidpassword'], []
96
+            ]);
97
+            return new RedirectResponse($this->urlGenerator->linkToRoute('user_ldap.renewPassword.showRenewPasswordForm', $args));
98
+        }
99 99
 
100
-		try {
101
-			if (!is_null($newPassword) && \OC_User::setPassword($user, $newPassword)) {
102
-				$this->session->set('loginMessages', [
103
-					[], [$this->l10n->t('Please login with the new password')]
104
-				]);
105
-				$this->userConfig->setValueBool($user, 'user_ldap', 'needsPasswordReset', false);
106
-				return new RedirectResponse($this->urlGenerator->linkToRoute('core.login.showLoginForm', $args));
107
-			} else {
108
-				$this->session->set('renewPasswordMessages', [
109
-					['internalexception'], []
110
-				]);
111
-			}
112
-		} catch (HintException $e) {
113
-			$this->session->set('renewPasswordMessages', [
114
-				[], [$e->getHint()]
115
-			]);
116
-		}
100
+        try {
101
+            if (!is_null($newPassword) && \OC_User::setPassword($user, $newPassword)) {
102
+                $this->session->set('loginMessages', [
103
+                    [], [$this->l10n->t('Please login with the new password')]
104
+                ]);
105
+                $this->userConfig->setValueBool($user, 'user_ldap', 'needsPasswordReset', false);
106
+                return new RedirectResponse($this->urlGenerator->linkToRoute('core.login.showLoginForm', $args));
107
+            } else {
108
+                $this->session->set('renewPasswordMessages', [
109
+                    ['internalexception'], []
110
+                ]);
111
+            }
112
+        } catch (HintException $e) {
113
+            $this->session->set('renewPasswordMessages', [
114
+                [], [$e->getHint()]
115
+            ]);
116
+        }
117 117
 
118
-		return new RedirectResponse($this->urlGenerator->linkToRoute('user_ldap.renewPassword.showRenewPasswordForm', $args));
119
-	}
118
+        return new RedirectResponse($this->urlGenerator->linkToRoute('user_ldap.renewPassword.showRenewPasswordForm', $args));
119
+    }
120 120
 
121
-	#[PublicPage]
122
-	#[NoCSRFRequired]
123
-	#[UseSession]
124
-	public function showLoginFormInvalidPassword(?string $user): RedirectResponse {
125
-		$args = !is_null($user) ? ['user' => $user] : [];
126
-		$this->session->set('loginMessages', [
127
-			['invalidpassword'], []
128
-		]);
129
-		return new RedirectResponse($this->urlGenerator->linkToRoute('core.login.showLoginForm', $args));
130
-	}
121
+    #[PublicPage]
122
+    #[NoCSRFRequired]
123
+    #[UseSession]
124
+    public function showLoginFormInvalidPassword(?string $user): RedirectResponse {
125
+        $args = !is_null($user) ? ['user' => $user] : [];
126
+        $this->session->set('loginMessages', [
127
+            ['invalidpassword'], []
128
+        ]);
129
+        return new RedirectResponse($this->urlGenerator->linkToRoute('core.login.showLoginForm', $args));
130
+    }
131 131
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/AppInfo/Application.php 1 patch
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -49,108 +49,108 @@
 block discarded – undo
49 49
 use Psr\Log\LoggerInterface;
50 50
 
51 51
 class Application extends App implements IBootstrap {
52
-	public const APP_ID = 'user_ldap';
52
+    public const APP_ID = 'user_ldap';
53 53
 
54
-	public function __construct() {
55
-		parent::__construct(self::APP_ID);
56
-		$container = $this->getContainer();
54
+    public function __construct() {
55
+        parent::__construct(self::APP_ID);
56
+        $container = $this->getContainer();
57 57
 
58
-		/**
59
-		 * Controller
60
-		 */
61
-		$container->registerService('RenewPasswordController', function (ContainerInterface $appContainer) {
62
-			return new RenewPasswordController(
63
-				$appContainer->get('AppName'),
64
-				$appContainer->get(IRequest::class),
65
-				$appContainer->get(IUserManager::class),
66
-				$appContainer->get(IConfig::class),
67
-				$appContainer->get(IUserConfig::class),
68
-				$appContainer->get(IL10N::class),
69
-				$appContainer->get('Session'),
70
-				$appContainer->get(IURLGenerator::class),
71
-				$appContainer->get(IInitialState::class),
72
-			);
73
-		});
58
+        /**
59
+         * Controller
60
+         */
61
+        $container->registerService('RenewPasswordController', function (ContainerInterface $appContainer) {
62
+            return new RenewPasswordController(
63
+                $appContainer->get('AppName'),
64
+                $appContainer->get(IRequest::class),
65
+                $appContainer->get(IUserManager::class),
66
+                $appContainer->get(IConfig::class),
67
+                $appContainer->get(IUserConfig::class),
68
+                $appContainer->get(IL10N::class),
69
+                $appContainer->get('Session'),
70
+                $appContainer->get(IURLGenerator::class),
71
+                $appContainer->get(IInitialState::class),
72
+            );
73
+        });
74 74
 
75
-		$container->registerService(ILDAPWrapper::class, function (ContainerInterface $appContainer) {
76
-			return new LDAP(
77
-				$appContainer->get(IConfig::class)->getSystemValueString('ldap_log_file')
78
-			);
79
-		});
80
-	}
75
+        $container->registerService(ILDAPWrapper::class, function (ContainerInterface $appContainer) {
76
+            return new LDAP(
77
+                $appContainer->get(IConfig::class)->getSystemValueString('ldap_log_file')
78
+            );
79
+        });
80
+    }
81 81
 
82
-	public function register(IRegistrationContext $context): void {
83
-		$context->registerNotifierService(Notifier::class);
82
+    public function register(IRegistrationContext $context): void {
83
+        $context->registerNotifierService(Notifier::class);
84 84
 
85
-		$context->registerService(
86
-			Manager::class,
87
-			function (ContainerInterface $c) {
88
-				return new Manager(
89
-					$c->get(IConfig::class),
90
-					$c->get(IUserConfig::class),
91
-					$c->get(IAppConfig::class),
92
-					$c->get(LoggerInterface::class),
93
-					$c->get(IAvatarManager::class),
94
-					$c->get(Image::class),
95
-					$c->get(IUserManager::class),
96
-					$c->get(INotificationManager::class),
97
-					$c->get(IShareManager::class),
98
-				);
99
-			},
100
-			// the instance is specific to a lazy bound Access instance, thus cannot be shared.
101
-			false
102
-		);
103
-		$context->registerEventListener(PostLoginEvent::class, LoginListener::class);
104
-		$context->registerSetupCheck(LdapInvalidUuids::class);
105
-		$context->registerSetupCheck(LdapConnection::class);
106
-	}
85
+        $context->registerService(
86
+            Manager::class,
87
+            function (ContainerInterface $c) {
88
+                return new Manager(
89
+                    $c->get(IConfig::class),
90
+                    $c->get(IUserConfig::class),
91
+                    $c->get(IAppConfig::class),
92
+                    $c->get(LoggerInterface::class),
93
+                    $c->get(IAvatarManager::class),
94
+                    $c->get(Image::class),
95
+                    $c->get(IUserManager::class),
96
+                    $c->get(INotificationManager::class),
97
+                    $c->get(IShareManager::class),
98
+                );
99
+            },
100
+            // the instance is specific to a lazy bound Access instance, thus cannot be shared.
101
+            false
102
+        );
103
+        $context->registerEventListener(PostLoginEvent::class, LoginListener::class);
104
+        $context->registerSetupCheck(LdapInvalidUuids::class);
105
+        $context->registerSetupCheck(LdapConnection::class);
106
+    }
107 107
 
108
-	public function boot(IBootContext $context): void {
109
-		$context->injectFn(function (
110
-			INotificationManager $notificationManager,
111
-			IAppContainer $appContainer,
112
-			IEventDispatcher $dispatcher,
113
-			IUserManager $userManager,
114
-			IGroupManager $groupManager,
115
-			User_Proxy $userBackend,
116
-			Group_Proxy $groupBackend,
117
-			Helper $helper,
118
-		): void {
119
-			$configPrefixes = $helper->getServerConfigurationPrefixes(true);
120
-			if (count($configPrefixes) > 0) {
121
-				$userPluginManager = $appContainer->get(UserPluginManager::class);
122
-				$groupPluginManager = $appContainer->get(GroupPluginManager::class);
108
+    public function boot(IBootContext $context): void {
109
+        $context->injectFn(function (
110
+            INotificationManager $notificationManager,
111
+            IAppContainer $appContainer,
112
+            IEventDispatcher $dispatcher,
113
+            IUserManager $userManager,
114
+            IGroupManager $groupManager,
115
+            User_Proxy $userBackend,
116
+            Group_Proxy $groupBackend,
117
+            Helper $helper,
118
+        ): void {
119
+            $configPrefixes = $helper->getServerConfigurationPrefixes(true);
120
+            if (count($configPrefixes) > 0) {
121
+                $userPluginManager = $appContainer->get(UserPluginManager::class);
122
+                $groupPluginManager = $appContainer->get(GroupPluginManager::class);
123 123
 
124
-				$userManager->registerBackend($userBackend);
125
-				$groupManager->addBackend($groupBackend);
124
+                $userManager->registerBackend($userBackend);
125
+                $groupManager->addBackend($groupBackend);
126 126
 
127
-				$userBackendRegisteredEvent = new UserBackendRegistered($userBackend, $userPluginManager);
128
-				$dispatcher->dispatch('OCA\\User_LDAP\\User\\User::postLDAPBackendAdded', $userBackendRegisteredEvent);
129
-				$dispatcher->dispatchTyped($userBackendRegisteredEvent);
130
-				$groupBackendRegisteredEvent = new GroupBackendRegistered($groupBackend, $groupPluginManager);
131
-				$dispatcher->dispatchTyped($groupBackendRegisteredEvent);
132
-			}
133
-		});
127
+                $userBackendRegisteredEvent = new UserBackendRegistered($userBackend, $userPluginManager);
128
+                $dispatcher->dispatch('OCA\\User_LDAP\\User\\User::postLDAPBackendAdded', $userBackendRegisteredEvent);
129
+                $dispatcher->dispatchTyped($userBackendRegisteredEvent);
130
+                $groupBackendRegisteredEvent = new GroupBackendRegistered($groupBackend, $groupPluginManager);
131
+                $dispatcher->dispatchTyped($groupBackendRegisteredEvent);
132
+            }
133
+        });
134 134
 
135
-		$context->injectFn(Closure::fromCallable([$this, 'registerBackendDependents']));
135
+        $context->injectFn(Closure::fromCallable([$this, 'registerBackendDependents']));
136 136
 
137
-		Util::connectHook(
138
-			'\OCA\Files_Sharing\API\Server2Server',
139
-			'preLoginNameUsedAsUserName',
140
-			'\OCA\User_LDAP\Helper',
141
-			'loginName2UserName'
142
-		);
143
-	}
137
+        Util::connectHook(
138
+            '\OCA\Files_Sharing\API\Server2Server',
139
+            'preLoginNameUsedAsUserName',
140
+            '\OCA\User_LDAP\Helper',
141
+            'loginName2UserName'
142
+        );
143
+    }
144 144
 
145
-	private function registerBackendDependents(IAppContainer $appContainer, IEventDispatcher $dispatcher): void {
146
-		$dispatcher->addListener(
147
-			'OCA\\Files_External::loadAdditionalBackends',
148
-			function () use ($appContainer): void {
149
-				$storagesBackendService = $appContainer->get(BackendService::class);
150
-				$storagesBackendService->registerConfigHandler('home', function () use ($appContainer) {
151
-					return $appContainer->get(ExtStorageConfigHandler::class);
152
-				});
153
-			}
154
-		);
155
-	}
145
+    private function registerBackendDependents(IAppContainer $appContainer, IEventDispatcher $dispatcher): void {
146
+        $dispatcher->addListener(
147
+            'OCA\\Files_External::loadAdditionalBackends',
148
+            function () use ($appContainer): void {
149
+                $storagesBackendService = $appContainer->get(BackendService::class);
150
+                $storagesBackendService->registerConfigHandler('home', function () use ($appContainer) {
151
+                    return $appContainer->get(ExtStorageConfigHandler::class);
152
+                });
153
+            }
154
+        );
155
+    }
156 156
 }
Please login to merge, or discard this patch.