Skip to content

Commit 32a02b0

Browse files
ChristophWurstnextcloud-command
authored andcommitted
fix: Show error message when CSRF check fails at login
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
1 parent 90529e5 commit 32a02b0

5 files changed

Lines changed: 18 additions & 4 deletions

File tree

core/Controller/LoginController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
class LoginController extends Controller {
6363
public const LOGIN_MSG_INVALIDPASSWORD = 'invalidpassword';
6464
public const LOGIN_MSG_USERDISABLED = 'userdisabled';
65+
public const LOGIN_MSG_CSRFCHECKFAILED = 'csrfCheckFailed';
6566

6667
private IUserManager $userManager;
6768
private IConfig $config;
@@ -311,7 +312,7 @@ public function tryLogin(Chain $loginChain,
311312
$user,
312313
$user,
313314
$redirect_url,
314-
$this->l10n->t('Please try again')
315+
self::LOGIN_MSG_CSRFCHECKFAILED
315316
);
316317
}
317318

core/src/components/login/LoginForm.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
type="warning">
3333
{{ t('core', 'Please contact your administrator.') }}
3434
</NcNoteCard>
35+
<NcNoteCard v-if="csrfCheckFailed"
36+
:heading="t('core', 'Temporary error')"
37+
type="error">
38+
{{ t('core', 'Please try again.') }}
39+
</NcNoteCard>
3540
<NcNoteCard v-if="messages.length > 0">
3641
<div v-for="(message, index) in messages"
3742
:key="index">
@@ -186,6 +191,9 @@ export default {
186191
apacheAuthFailed() {
187192
return this.errors.indexOf('apacheAuthFailed') !== -1
188193
},
194+
csrfCheckFailed() {
195+
return this.errors.indexOf('csrfCheckFailed') !== -1
196+
},
189197
internalException() {
190198
return this.errors.indexOf('internalexception') !== -1
191199
},

dist/core-login.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-login.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/private/Authentication/Login/LoginResult.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*/
2626
namespace OC\Authentication\Login;
2727

28+
use OC\Core\Controller\LoginController;
29+
2830
class LoginResult {
2931
/** @var bool */
3032
private $success;
@@ -59,6 +61,9 @@ public static function success(LoginData $data, ?string $redirectUrl = null) {
5961
return $result;
6062
}
6163

64+
/**
65+
* @param LoginController::LOGIN_MSG_*|null $msg
66+
*/
6267
public static function failure(LoginData $data, string $msg = null): LoginResult {
6368
$result = new static(false, $data);
6469
if ($msg !== null) {

0 commit comments

Comments
 (0)