-
Notifications
You must be signed in to change notification settings - Fork 0
/
masterpassword.patch
75 lines (71 loc) · 3.32 KB
/
masterpassword.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
From 4bab7007bc158adf5f53fe3b20d30f34fa612333 Mon Sep 17 00:00:00 2001
From: Micke Nordin <[email protected]>
Date: Fri, 17 May 2024 12:07:55 +0200
Subject: [PATCH] fix(provisioning): Set master password for passwordless
sessions
Signed-off-by: Micke Nordin <[email protected]>
---
.../Middleware/ProvisioningMiddleware.php | 11 ---------
lib/Service/Provisioning/Manager.php | 23 ++++++++++++++-----
2 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/lib/Http/Middleware/ProvisioningMiddleware.php b/lib/Http/Middleware/ProvisioningMiddleware.php
index 263114647b..a2445a87a1 100644
--- a/lib/Http/Middleware/ProvisioningMiddleware.php
+++ b/lib/Http/Middleware/ProvisioningMiddleware.php
@@ -70,17 +70,6 @@ public function beforeController($controller, $methodName) {
try {
$this->provisioningManager->provisionSingleUser($configs, $user);
$password = $this->credentialStore->getLoginCredentials()->getPassword();
-
- // FIXME: Need to check for an empty string here too?
- // The password is empty (and not null) when using WebAuthn passwordless login.
- // Maybe research other providers as well.
- // Ref \OCA\Mail\Controller\PageController::index()
- // -> inital state for password-is-unavailable
- if ($password === null) {
- // Nothing to update, might be passwordless signin
- $this->logger->debug('No password set for ' . $user->getUID());
- return;
- }
$this->provisioningManager->updatePassword(
$user,
$password,
diff --git a/lib/Service/Provisioning/Manager.php b/lib/Service/Provisioning/Manager.php
index 8c949f8c80..2617a4d1ee 100644
--- a/lib/Service/Provisioning/Manager.php
+++ b/lib/Service/Provisioning/Manager.php
@@ -319,7 +319,7 @@ public function deprovision(Provisioning $provisioning): void {
/**
* @param Provisioning[] $provisionings
*/
- public function updatePassword(IUser $user, string $password, array $provisionings): void {
+ public function updatePassword(IUser $user, ?string $password, array $provisionings): void {
try {
$account = $this->mailAccountMapper->findProvisionedAccount($user);
@@ -327,11 +327,22 @@ public function updatePassword(IUser $user, string $password, array $provisionin
if ($provisioning === null) {
return;
}
- $masterPassword = $provisioning->getMasterPassword();
- $masterPasswordEnabled = $provisioning->getMasterPasswordEnabled();
- if ($masterPasswordEnabled && $masterPassword !== null) {
- $password = $masterPassword;
- $this->logger->debug('Password set to master password for ' . $user->getUID());
+
+ // FIXME: Need to check for an empty string here too?
+ // The password is empty (and not null) when using WebAuthn passwordless login.
+ // Maybe research other providers as well.
+ // Ref \OCA\Mail\Controller\PageController::index()
+ // -> inital state for password-is-unavailable
+ if ($password === null) {
+ $masterPassword = $provisioning->getMasterPassword();
+ $masterPasswordEnabled = $provisioning->getMasterPasswordEnabled();
+ if ($masterPasswordEnabled && $masterPassword !== null) {
+ $password = $masterPassword;
+ $this->logger->debug('Password set to master password for ' . $user->getUID());
+ } else {
+ $this->logger->debug('No password set for ' . $user->getUID());
+ return;
+ }
}
if (!empty($account->getInboundPassword())