Skip to content

Commit 4d0e11e

Browse files
fix: Show error message when CSRF check fails at login
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
1 parent 20516a9 commit 4d0e11e

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
@@ -64,6 +64,7 @@
6464
class LoginController extends Controller {
6565
public const LOGIN_MSG_INVALIDPASSWORD = 'invalidpassword';
6666
public const LOGIN_MSG_USERDISABLED = 'userdisabled';
67+
public const LOGIN_MSG_CSRFCHECKFAILED = 'csrfCheckFailed';
6768

6869
public function __construct(
6970
?string $appName,
@@ -291,7 +292,7 @@ public function tryLogin(Chain $loginChain,
291292
$user,
292293
$user,
293294
$redirect_url,
294-
$this->l10n->t('Please try again')
295+
self::LOGIN_MSG_CSRFCHECKFAILED
295296
);
296297
}
297298

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">
@@ -184,6 +189,9 @@ export default {
184189
apacheAuthFailed() {
185190
return this.errors.indexOf('apacheAuthFailed') !== -1
186191
},
192+
csrfCheckFailed() {
193+
return this.errors.indexOf('csrfCheckFailed') !== -1
194+
},
187195
internalException() {
188196
return this.errors.indexOf('internalexception') !== -1
189197
},

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)