@@ -91,9 +91,18 @@ public static function startApp(bool $handle = false)
91
91
*/
92
92
if ($ doLogin && $ aCredentials [1 ] && $ aCredentials [2 ]) {
93
93
try {
94
- $ oAccount = $ oActions ->LoginProcess ($ aCredentials [1 ], $ aCredentials [2 ]);
95
- if ($ oAccount && $ oConfig ->Get ('login ' , 'sign_me_auto ' , \RainLoop \Enumerations \SignMeType::DefaultOff) === \RainLoop \Enumerations \SignMeType::DefaultOn) {
96
- $ oActions ->SetSignMeToken ($ oAccount );
94
+ $ ocSession = \OC ::$ server ->getSession ();
95
+ if ($ ocSession ->get ('is_oidc ' )) {
96
+ $ pwd = new \SnappyMail \SensitiveString ($ aCredentials [1 ]);
97
+ $ oAccount = $ oActions ->LoginProcess ($ aCredentials [1 ], $ pwd );
98
+ if ($ oAccount ) {
99
+ $ oActions ->SetSignMeToken ($ oAccount );
100
+ }
101
+ } else {
102
+ $ oAccount = $ oActions ->LoginProcess ($ aCredentials [1 ], $ aCredentials [2 ]);
103
+ if ($ oAccount && $ oConfig ->Get ('login ' , 'sign_me_auto ' , \RainLoop \Enumerations \SignMeType::DefaultOff) === \RainLoop \Enumerations \SignMeType::DefaultOn) {
104
+ $ oActions ->SetSignMeToken ($ oAccount );
105
+ }
97
106
}
98
107
} catch (\Throwable $ e ) {
99
108
// Login failure, reset password to prevent more attempts
@@ -140,22 +149,22 @@ private static function getLoginCredentials() : array
140
149
// If the current user ID is identical to login ID (not valid when using account switching),
141
150
// this has the second priority.
142
151
if ($ ocSession ['snappymail-nc-uid ' ] == $ sUID ) {
143
- /*
152
+
144
153
// If OpenID Connect (OIDC) is enabled and used for login, use this.
145
154
// https://apps.nextcloud.com/apps/oidc_login
146
- // DISABLED https://github.com/the-djmaze/snappymail/issues/1420#issuecomment-1933045917
147
155
if ($ config ->getAppValue ('snappymail ' , 'snappymail-autologin-oidc ' , false )) {
148
156
if ($ ocSession ->get ('is_oidc ' )) {
149
157
// IToken->getPassword() ???
150
158
if ($ sAccessToken = $ ocSession ->get ('oidc_access_token ' )) {
151
- return [$sUID, 'oidc@nextcloud', $sAccessToken];
159
+ $ sEmail = $ config ->getUserValue ($ sUID , 'settings ' , 'email ' );
160
+ return [$ sUID , $ sEmail , $ sAccessToken ];
152
161
}
153
162
\SnappyMail \Log::debug ('Nextcloud ' , 'OIDC access_token missing ' );
154
163
} else {
155
164
\SnappyMail \Log::debug ('Nextcloud ' , 'No OIDC login ' );
156
165
}
157
166
}
158
- */
167
+
159
168
// Only use the user's password in the current session if they have
160
169
// enabled auto-login using Nextcloud username or email address.
161
170
$ sEmail = '' ;
0 commit comments