Completed
Pull Request — master (#9632)
by Christoph
54:37 queued 30:46
created
lib/private/Authentication/TwoFactorAuth/Manager.php 1 patch
Indentation   +327 added lines, -327 removed lines patch added patch discarded remove patch
@@ -44,335 +44,335 @@
 block discarded – undo
44 44
 
45 45
 class Manager {
46 46
 
47
-	const SESSION_UID_KEY = 'two_factor_auth_uid';
48
-	const SESSION_UID_DONE = 'two_factor_auth_passed';
49
-	const REMEMBER_LOGIN = 'two_factor_remember_login';
50
-
51
-	/** @var ProviderLoader */
52
-	private $providerLoader;
53
-
54
-	/** @var IRegistry */
55
-	private $providerRegistry;
56
-
57
-	/** @var ISession */
58
-	private $session;
59
-
60
-	/** @var IConfig */
61
-	private $config;
62
-
63
-	/** @var IManager */
64
-	private $activityManager;
65
-
66
-	/** @var ILogger */
67
-	private $logger;
68
-
69
-	/** @var TokenProvider */
70
-	private $tokenProvider;
71
-
72
-	/** @var ITimeFactory */
73
-	private $timeFactory;
74
-
75
-	/** @var EventDispatcherInterface */
76
-	private $dispatcher;
77
-
78
-	public function __construct(ProviderLoader $providerLoader,
79
-		IRegistry $providerRegistry, ISession $session, IConfig $config,
80
-		IManager $activityManager, ILogger $logger, TokenProvider $tokenProvider,
81
-		ITimeFactory $timeFactory, EventDispatcherInterface $eventDispatcher) {
82
-		$this->providerLoader = $providerLoader;
83
-		$this->session = $session;
84
-		$this->config = $config;
85
-		$this->activityManager = $activityManager;
86
-		$this->logger = $logger;
87
-		$this->tokenProvider = $tokenProvider;
88
-		$this->timeFactory = $timeFactory;
89
-		$this->dispatcher = $eventDispatcher;
90
-		$this->providerRegistry = $providerRegistry;
91
-	}
92
-
93
-	/**
94
-	 * Determine whether the user must provide a second factor challenge
95
-	 *
96
-	 * @param IUser $user
97
-	 * @return boolean
98
-	 */
99
-	public function isTwoFactorAuthenticated(IUser $user): bool {
100
-		$twoFactorEnabled = ((int) $this->config->getUserValue($user->getUID(), 'core', 'two_factor_auth_disabled', 0)) === 0;
101
-
102
-		if (!$twoFactorEnabled) {
103
-			return false;
104
-		}
105
-
106
-		$providerStates = $this->providerRegistry->getProviderStates($user);
107
-		$enabled = array_filter($providerStates);
108
-
109
-		return $twoFactorEnabled && !empty($enabled);
110
-	}
111
-
112
-	/**
113
-	 * Disable 2FA checks for the given user
114
-	 *
115
-	 * @param IUser $user
116
-	 */
117
-	public function disableTwoFactorAuthentication(IUser $user) {
118
-		$this->config->setUserValue($user->getUID(), 'core', 'two_factor_auth_disabled', 1);
119
-	}
120
-
121
-	/**
122
-	 * Enable all 2FA checks for the given user
123
-	 *
124
-	 * @param IUser $user
125
-	 */
126
-	public function enableTwoFactorAuthentication(IUser $user) {
127
-		$this->config->deleteUserValue($user->getUID(), 'core', 'two_factor_auth_disabled');
128
-	}
129
-
130
-	/**
131
-	 * Get a 2FA provider by its ID
132
-	 *
133
-	 * @param IUser $user
134
-	 * @param string $challengeProviderId
135
-	 * @return IProvider|null
136
-	 */
137
-	public function getProvider(IUser $user, string $challengeProviderId) {
138
-		$providers = $this->getProviderSet($user)->getProviders();
139
-		return $providers[$challengeProviderId] ?? null;
140
-	}
141
-
142
-	/**
143
-	 * Check if the persistant mapping of enabled/disabled state of each available
144
-	 * provider is missing an entry and add it to the registry in that case.
145
-	 *
146
-	 * @todo remove in Nextcloud 17 as by then all providers should have been updated
147
-	 *
148
-	 * @param string[] $providerStates
149
-	 * @param IProvider[] $providers
150
-	 * @param IUser $user
151
-	 * @return string[] the updated $providerStates variable
152
-	 */
153
-	private function fixMissingProviderStates(array $providerStates,
154
-		array $providers, IUser $user): array {
155
-
156
-		foreach ($providers as $provider) {
157
-			if (isset($providerStates[$provider->getId()])) {
158
-				// All good
159
-				continue;
160
-			}
161
-
162
-			$enabled = $provider->isTwoFactorAuthEnabledForUser($user);
163
-			if ($enabled) {
164
-				$this->providerRegistry->enableProviderFor($provider, $user);
165
-			} else {
166
-				$this->providerRegistry->disableProviderFor($provider, $user);
167
-			}
168
-			$providerStates[$provider->getId()] = $enabled;
169
-		}
170
-
171
-		return $providerStates;
172
-	}
173
-
174
-	/**
175
-	 * @param array $states
176
-	 * @param IProvider $providers
177
-	 */
178
-	private function isProviderMissing(array $states, array $providers): bool {
179
-		$indexed = [];
180
-		foreach ($providers as $provider) {
181
-			$indexed[$provider->getId()] = $provider;
182
-		}
183
-
184
-		$missing = [];
185
-		foreach ($states as $providerId => $enabled) {
186
-			if (!$enabled) {
187
-				// Don't care
188
-				continue;
189
-			}
190
-
191
-			if (!isset($indexed[$providerId])) {
192
-				$missing[] = $providerId;
193
-				$this->logger->alert("two-factor auth provider '$providerId' failed to load",
194
-					[
195
-					'app' => 'core',
196
-				]);
197
-			}
198
-		}
199
-
200
-		if (!empty($missing)) {
201
-			// There was at least one provider missing
202
-			$this->logger->alert(count($missing) . " two-factor auuth providers failed to load",
203
-				[
204
-				'app' => 'core',
205
-			]);
206
-
207
-			return true;
208
-		}
209
-
210
-		// If we reach this, there was not a single provider missing
211
-		return false;
212
-	}
213
-
214
-	/**
215
-	 * Get the list of 2FA providers for the given user
216
-	 *
217
-	 * @param IUser $user
218
-	 * @throws Exception
219
-	 */
220
-	public function getProviderSet(IUser $user): ProviderSet {
221
-		$providerStates = $this->providerRegistry->getProviderStates($user);
222
-		$providers = $this->providerLoader->getProviders($user);
223
-
224
-		$fixedStates = $this->fixMissingProviderStates($providerStates, $providers, $user);
225
-		$isProviderMissing = $this->isProviderMissing($fixedStates, $providers);
226
-
227
-		$enabled = array_filter($providers,
228
-			function (IProvider $provider) use ($fixedStates) {
229
-			return $fixedStates[$provider->getId()];
230
-		});
231
-		return new ProviderSet($enabled, $isProviderMissing);
232
-	}
233
-
234
-	/**
235
-	 * Verify the given challenge
236
-	 *
237
-	 * @param string $providerId
238
-	 * @param IUser $user
239
-	 * @param string $challenge
240
-	 * @return boolean
241
-	 */
242
-	public function verifyChallenge(string $providerId, IUser $user, string $challenge): bool {
243
-		$provider = $this->getProvider($user, $providerId);
244
-		if ($provider === null) {
245
-			return false;
246
-		}
247
-
248
-		$passed = $provider->verifyChallenge($user, $challenge);
249
-		if ($passed) {
250
-			if ($this->session->get(self::REMEMBER_LOGIN) === true) {
251
-				// TODO: resolve cyclic dependency and use DI
252
-				\OC::$server->getUserSession()->createRememberMeToken($user);
253
-			}
254
-			$this->session->remove(self::SESSION_UID_KEY);
255
-			$this->session->remove(self::REMEMBER_LOGIN);
256
-			$this->session->set(self::SESSION_UID_DONE, $user->getUID());
257
-
258
-			// Clear token from db
259
-			$sessionId = $this->session->getId();
260
-			$token = $this->tokenProvider->getToken($sessionId);
261
-			$tokenId = $token->getId();
262
-			$this->config->deleteUserValue($user->getUID(), 'login_token_2fa', $tokenId);
263
-
264
-			$dispatchEvent = new GenericEvent($user, ['provider' => $provider->getDisplayName()]);
265
-			$this->dispatcher->dispatch(IProvider::EVENT_SUCCESS, $dispatchEvent);
266
-
267
-			$this->publishEvent($user, 'twofactor_success', [
268
-				'provider' => $provider->getDisplayName(),
269
-			]);
270
-		} else {
271
-			$dispatchEvent = new GenericEvent($user, ['provider' => $provider->getDisplayName()]);
272
-			$this->dispatcher->dispatch(IProvider::EVENT_FAILED, $dispatchEvent);
273
-
274
-			$this->publishEvent($user, 'twofactor_failed', [
275
-				'provider' => $provider->getDisplayName(),
276
-			]);
277
-		}
278
-		return $passed;
279
-	}
280
-
281
-	/**
282
-	 * Push a 2fa event the user's activity stream
283
-	 *
284
-	 * @param IUser $user
285
-	 * @param string $event
286
-	 * @param array $params
287
-	 */
288
-	private function publishEvent(IUser $user, string $event, array $params) {
289
-		$activity = $this->activityManager->generateEvent();
290
-		$activity->setApp('core')
291
-			->setType('security')
292
-			->setAuthor($user->getUID())
293
-			->setAffectedUser($user->getUID())
294
-			->setSubject($event, $params);
295
-		try {
296
-			$this->activityManager->publish($activity);
297
-		} catch (BadMethodCallException $e) {
298
-			$this->logger->warning('could not publish activity', ['app' => 'core']);
299
-			$this->logger->logException($e, ['app' => 'core']);
300
-		}
301
-	}
302
-
303
-	/**
304
-	 * Check if the currently logged in user needs to pass 2FA
305
-	 *
306
-	 * @param IUser $user the currently logged in user
307
-	 * @return boolean
308
-	 */
309
-	public function needsSecondFactor(IUser $user = null): bool {
310
-		if ($user === null) {
311
-			return false;
312
-		}
313
-
314
-		// If we are authenticated using an app password skip all this
315
-		if ($this->session->exists('app_password')) {
316
-			return false;
317
-		}
318
-
319
-		// First check if the session tells us we should do 2FA (99% case)
320
-		if (!$this->session->exists(self::SESSION_UID_KEY)) {
321
-
322
-			// Check if the session tells us it is 2FA authenticated already
323
-			if ($this->session->exists(self::SESSION_UID_DONE) &&
324
-				$this->session->get(self::SESSION_UID_DONE) === $user->getUID()) {
325
-				return false;
326
-			}
327
-
328
-			/*
47
+    const SESSION_UID_KEY = 'two_factor_auth_uid';
48
+    const SESSION_UID_DONE = 'two_factor_auth_passed';
49
+    const REMEMBER_LOGIN = 'two_factor_remember_login';
50
+
51
+    /** @var ProviderLoader */
52
+    private $providerLoader;
53
+
54
+    /** @var IRegistry */
55
+    private $providerRegistry;
56
+
57
+    /** @var ISession */
58
+    private $session;
59
+
60
+    /** @var IConfig */
61
+    private $config;
62
+
63
+    /** @var IManager */
64
+    private $activityManager;
65
+
66
+    /** @var ILogger */
67
+    private $logger;
68
+
69
+    /** @var TokenProvider */
70
+    private $tokenProvider;
71
+
72
+    /** @var ITimeFactory */
73
+    private $timeFactory;
74
+
75
+    /** @var EventDispatcherInterface */
76
+    private $dispatcher;
77
+
78
+    public function __construct(ProviderLoader $providerLoader,
79
+        IRegistry $providerRegistry, ISession $session, IConfig $config,
80
+        IManager $activityManager, ILogger $logger, TokenProvider $tokenProvider,
81
+        ITimeFactory $timeFactory, EventDispatcherInterface $eventDispatcher) {
82
+        $this->providerLoader = $providerLoader;
83
+        $this->session = $session;
84
+        $this->config = $config;
85
+        $this->activityManager = $activityManager;
86
+        $this->logger = $logger;
87
+        $this->tokenProvider = $tokenProvider;
88
+        $this->timeFactory = $timeFactory;
89
+        $this->dispatcher = $eventDispatcher;
90
+        $this->providerRegistry = $providerRegistry;
91
+    }
92
+
93
+    /**
94
+     * Determine whether the user must provide a second factor challenge
95
+     *
96
+     * @param IUser $user
97
+     * @return boolean
98
+     */
99
+    public function isTwoFactorAuthenticated(IUser $user): bool {
100
+        $twoFactorEnabled = ((int) $this->config->getUserValue($user->getUID(), 'core', 'two_factor_auth_disabled', 0)) === 0;
101
+
102
+        if (!$twoFactorEnabled) {
103
+            return false;
104
+        }
105
+
106
+        $providerStates = $this->providerRegistry->getProviderStates($user);
107
+        $enabled = array_filter($providerStates);
108
+
109
+        return $twoFactorEnabled && !empty($enabled);
110
+    }
111
+
112
+    /**
113
+     * Disable 2FA checks for the given user
114
+     *
115
+     * @param IUser $user
116
+     */
117
+    public function disableTwoFactorAuthentication(IUser $user) {
118
+        $this->config->setUserValue($user->getUID(), 'core', 'two_factor_auth_disabled', 1);
119
+    }
120
+
121
+    /**
122
+     * Enable all 2FA checks for the given user
123
+     *
124
+     * @param IUser $user
125
+     */
126
+    public function enableTwoFactorAuthentication(IUser $user) {
127
+        $this->config->deleteUserValue($user->getUID(), 'core', 'two_factor_auth_disabled');
128
+    }
129
+
130
+    /**
131
+     * Get a 2FA provider by its ID
132
+     *
133
+     * @param IUser $user
134
+     * @param string $challengeProviderId
135
+     * @return IProvider|null
136
+     */
137
+    public function getProvider(IUser $user, string $challengeProviderId) {
138
+        $providers = $this->getProviderSet($user)->getProviders();
139
+        return $providers[$challengeProviderId] ?? null;
140
+    }
141
+
142
+    /**
143
+     * Check if the persistant mapping of enabled/disabled state of each available
144
+     * provider is missing an entry and add it to the registry in that case.
145
+     *
146
+     * @todo remove in Nextcloud 17 as by then all providers should have been updated
147
+     *
148
+     * @param string[] $providerStates
149
+     * @param IProvider[] $providers
150
+     * @param IUser $user
151
+     * @return string[] the updated $providerStates variable
152
+     */
153
+    private function fixMissingProviderStates(array $providerStates,
154
+        array $providers, IUser $user): array {
155
+
156
+        foreach ($providers as $provider) {
157
+            if (isset($providerStates[$provider->getId()])) {
158
+                // All good
159
+                continue;
160
+            }
161
+
162
+            $enabled = $provider->isTwoFactorAuthEnabledForUser($user);
163
+            if ($enabled) {
164
+                $this->providerRegistry->enableProviderFor($provider, $user);
165
+            } else {
166
+                $this->providerRegistry->disableProviderFor($provider, $user);
167
+            }
168
+            $providerStates[$provider->getId()] = $enabled;
169
+        }
170
+
171
+        return $providerStates;
172
+    }
173
+
174
+    /**
175
+     * @param array $states
176
+     * @param IProvider $providers
177
+     */
178
+    private function isProviderMissing(array $states, array $providers): bool {
179
+        $indexed = [];
180
+        foreach ($providers as $provider) {
181
+            $indexed[$provider->getId()] = $provider;
182
+        }
183
+
184
+        $missing = [];
185
+        foreach ($states as $providerId => $enabled) {
186
+            if (!$enabled) {
187
+                // Don't care
188
+                continue;
189
+            }
190
+
191
+            if (!isset($indexed[$providerId])) {
192
+                $missing[] = $providerId;
193
+                $this->logger->alert("two-factor auth provider '$providerId' failed to load",
194
+                    [
195
+                    'app' => 'core',
196
+                ]);
197
+            }
198
+        }
199
+
200
+        if (!empty($missing)) {
201
+            // There was at least one provider missing
202
+            $this->logger->alert(count($missing) . " two-factor auuth providers failed to load",
203
+                [
204
+                'app' => 'core',
205
+            ]);
206
+
207
+            return true;
208
+        }
209
+
210
+        // If we reach this, there was not a single provider missing
211
+        return false;
212
+    }
213
+
214
+    /**
215
+     * Get the list of 2FA providers for the given user
216
+     *
217
+     * @param IUser $user
218
+     * @throws Exception
219
+     */
220
+    public function getProviderSet(IUser $user): ProviderSet {
221
+        $providerStates = $this->providerRegistry->getProviderStates($user);
222
+        $providers = $this->providerLoader->getProviders($user);
223
+
224
+        $fixedStates = $this->fixMissingProviderStates($providerStates, $providers, $user);
225
+        $isProviderMissing = $this->isProviderMissing($fixedStates, $providers);
226
+
227
+        $enabled = array_filter($providers,
228
+            function (IProvider $provider) use ($fixedStates) {
229
+            return $fixedStates[$provider->getId()];
230
+        });
231
+        return new ProviderSet($enabled, $isProviderMissing);
232
+    }
233
+
234
+    /**
235
+     * Verify the given challenge
236
+     *
237
+     * @param string $providerId
238
+     * @param IUser $user
239
+     * @param string $challenge
240
+     * @return boolean
241
+     */
242
+    public function verifyChallenge(string $providerId, IUser $user, string $challenge): bool {
243
+        $provider = $this->getProvider($user, $providerId);
244
+        if ($provider === null) {
245
+            return false;
246
+        }
247
+
248
+        $passed = $provider->verifyChallenge($user, $challenge);
249
+        if ($passed) {
250
+            if ($this->session->get(self::REMEMBER_LOGIN) === true) {
251
+                // TODO: resolve cyclic dependency and use DI
252
+                \OC::$server->getUserSession()->createRememberMeToken($user);
253
+            }
254
+            $this->session->remove(self::SESSION_UID_KEY);
255
+            $this->session->remove(self::REMEMBER_LOGIN);
256
+            $this->session->set(self::SESSION_UID_DONE, $user->getUID());
257
+
258
+            // Clear token from db
259
+            $sessionId = $this->session->getId();
260
+            $token = $this->tokenProvider->getToken($sessionId);
261
+            $tokenId = $token->getId();
262
+            $this->config->deleteUserValue($user->getUID(), 'login_token_2fa', $tokenId);
263
+
264
+            $dispatchEvent = new GenericEvent($user, ['provider' => $provider->getDisplayName()]);
265
+            $this->dispatcher->dispatch(IProvider::EVENT_SUCCESS, $dispatchEvent);
266
+
267
+            $this->publishEvent($user, 'twofactor_success', [
268
+                'provider' => $provider->getDisplayName(),
269
+            ]);
270
+        } else {
271
+            $dispatchEvent = new GenericEvent($user, ['provider' => $provider->getDisplayName()]);
272
+            $this->dispatcher->dispatch(IProvider::EVENT_FAILED, $dispatchEvent);
273
+
274
+            $this->publishEvent($user, 'twofactor_failed', [
275
+                'provider' => $provider->getDisplayName(),
276
+            ]);
277
+        }
278
+        return $passed;
279
+    }
280
+
281
+    /**
282
+     * Push a 2fa event the user's activity stream
283
+     *
284
+     * @param IUser $user
285
+     * @param string $event
286
+     * @param array $params
287
+     */
288
+    private function publishEvent(IUser $user, string $event, array $params) {
289
+        $activity = $this->activityManager->generateEvent();
290
+        $activity->setApp('core')
291
+            ->setType('security')
292
+            ->setAuthor($user->getUID())
293
+            ->setAffectedUser($user->getUID())
294
+            ->setSubject($event, $params);
295
+        try {
296
+            $this->activityManager->publish($activity);
297
+        } catch (BadMethodCallException $e) {
298
+            $this->logger->warning('could not publish activity', ['app' => 'core']);
299
+            $this->logger->logException($e, ['app' => 'core']);
300
+        }
301
+    }
302
+
303
+    /**
304
+     * Check if the currently logged in user needs to pass 2FA
305
+     *
306
+     * @param IUser $user the currently logged in user
307
+     * @return boolean
308
+     */
309
+    public function needsSecondFactor(IUser $user = null): bool {
310
+        if ($user === null) {
311
+            return false;
312
+        }
313
+
314
+        // If we are authenticated using an app password skip all this
315
+        if ($this->session->exists('app_password')) {
316
+            return false;
317
+        }
318
+
319
+        // First check if the session tells us we should do 2FA (99% case)
320
+        if (!$this->session->exists(self::SESSION_UID_KEY)) {
321
+
322
+            // Check if the session tells us it is 2FA authenticated already
323
+            if ($this->session->exists(self::SESSION_UID_DONE) &&
324
+                $this->session->get(self::SESSION_UID_DONE) === $user->getUID()) {
325
+                return false;
326
+            }
327
+
328
+            /*
329 329
 			 * If the session is expired check if we are not logged in by a token
330 330
 			 * that still needs 2FA auth
331 331
 			 */
332
-			try {
333
-				$sessionId = $this->session->getId();
334
-				$token = $this->tokenProvider->getToken($sessionId);
335
-				$tokenId = $token->getId();
336
-				$tokensNeeding2FA = $this->config->getUserKeys($user->getUID(), 'login_token_2fa');
337
-
338
-				if (!\in_array($tokenId, $tokensNeeding2FA, true)) {
339
-					$this->session->set(self::SESSION_UID_DONE, $user->getUID());
340
-					return false;
341
-				}
342
-			} catch (InvalidTokenException $e) {
343
-			}
344
-		}
345
-
346
-		if (!$this->isTwoFactorAuthenticated($user)) {
347
-			// There is no second factor any more -> let the user pass
348
-			//   This prevents infinite redirect loops when a user is about
349
-			//   to solve the 2FA challenge, and the provider app is
350
-			//   disabled the same time
351
-			$this->session->remove(self::SESSION_UID_KEY);
352
-
353
-			$keys = $this->config->getUserKeys($user->getUID(), 'login_token_2fa');
354
-			foreach ($keys as $key) {
355
-				$this->config->deleteUserValue($user->getUID(), 'login_token_2fa', $key);
356
-			}
357
-			return false;
358
-		}
359
-
360
-		return true;
361
-	}
362
-
363
-	/**
364
-	 * Prepare the 2FA login
365
-	 *
366
-	 * @param IUser $user
367
-	 * @param boolean $rememberMe
368
-	 */
369
-	public function prepareTwoFactorLogin(IUser $user, bool $rememberMe) {
370
-		$this->session->set(self::SESSION_UID_KEY, $user->getUID());
371
-		$this->session->set(self::REMEMBER_LOGIN, $rememberMe);
372
-
373
-		$id = $this->session->getId();
374
-		$token = $this->tokenProvider->getToken($id);
375
-		$this->config->setUserValue($user->getUID(), 'login_token_2fa', $token->getId(), $this->timeFactory->getTime());
376
-	}
332
+            try {
333
+                $sessionId = $this->session->getId();
334
+                $token = $this->tokenProvider->getToken($sessionId);
335
+                $tokenId = $token->getId();
336
+                $tokensNeeding2FA = $this->config->getUserKeys($user->getUID(), 'login_token_2fa');
337
+
338
+                if (!\in_array($tokenId, $tokensNeeding2FA, true)) {
339
+                    $this->session->set(self::SESSION_UID_DONE, $user->getUID());
340
+                    return false;
341
+                }
342
+            } catch (InvalidTokenException $e) {
343
+            }
344
+        }
345
+
346
+        if (!$this->isTwoFactorAuthenticated($user)) {
347
+            // There is no second factor any more -> let the user pass
348
+            //   This prevents infinite redirect loops when a user is about
349
+            //   to solve the 2FA challenge, and the provider app is
350
+            //   disabled the same time
351
+            $this->session->remove(self::SESSION_UID_KEY);
352
+
353
+            $keys = $this->config->getUserKeys($user->getUID(), 'login_token_2fa');
354
+            foreach ($keys as $key) {
355
+                $this->config->deleteUserValue($user->getUID(), 'login_token_2fa', $key);
356
+            }
357
+            return false;
358
+        }
359
+
360
+        return true;
361
+    }
362
+
363
+    /**
364
+     * Prepare the 2FA login
365
+     *
366
+     * @param IUser $user
367
+     * @param boolean $rememberMe
368
+     */
369
+    public function prepareTwoFactorLogin(IUser $user, bool $rememberMe) {
370
+        $this->session->set(self::SESSION_UID_KEY, $user->getUID());
371
+        $this->session->set(self::REMEMBER_LOGIN, $rememberMe);
372
+
373
+        $id = $this->session->getId();
374
+        $token = $this->tokenProvider->getToken($id);
375
+        $this->config->setUserValue($user->getUID(), 'login_token_2fa', $token->getId(), $this->timeFactory->getTime());
376
+    }
377 377
 
378 378
 }
Please login to merge, or discard this patch.
lib/private/Authentication/TwoFactorAuth/ProviderSet.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -31,38 +31,38 @@
 block discarded – undo
31 31
  */
32 32
 class ProviderSet {
33 33
 
34
-	/** @var IProvider */
35
-	private $providers;
34
+    /** @var IProvider */
35
+    private $providers;
36 36
 
37
-	/** @var bool */
38
-	private $providerMissing;
37
+    /** @var bool */
38
+    private $providerMissing;
39 39
 
40
-	/**
41
-	 * @param array $providers
42
-	 * @param bool $providerMissing
43
-	 */
44
-	public function __construct(array $providers, bool $providerMissing) {
45
-		$this->providers = $providers;
46
-		$this->providerMissing = $providerMissing;
47
-	}
40
+    /**
41
+     * @param array $providers
42
+     * @param bool $providerMissing
43
+     */
44
+    public function __construct(array $providers, bool $providerMissing) {
45
+        $this->providers = $providers;
46
+        $this->providerMissing = $providerMissing;
47
+    }
48 48
 
49
-	/**
50
-	 * @param string $providerId
51
-	 * @return IProvider|null
52
-	 */
53
-	public function getProvider(string $providerId) {
54
-		return $this->providers[$providerId] ?? null;
55
-	}
49
+    /**
50
+     * @param string $providerId
51
+     * @return IProvider|null
52
+     */
53
+    public function getProvider(string $providerId) {
54
+        return $this->providers[$providerId] ?? null;
55
+    }
56 56
 
57
-	/**
58
-	 * @return IProvider[]
59
-	 */
60
-	public function getProviders(): array {
61
-		return $this->providers;
62
-	}
57
+    /**
58
+     * @return IProvider[]
59
+     */
60
+    public function getProviders(): array {
61
+        return $this->providers;
62
+    }
63 63
 
64
-	public function isProviderMissing(): bool {
65
-		return $this->providerMissing;
66
-	}
64
+    public function isProviderMissing(): bool {
65
+        return $this->providerMissing;
66
+    }
67 67
 
68 68
 }
Please login to merge, or discard this patch.