Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable27] fix: Show error message when CSRF check fails at login #41970

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
class LoginController extends Controller {
public const LOGIN_MSG_INVALIDPASSWORD = 'invalidpassword';
public const LOGIN_MSG_USERDISABLED = 'userdisabled';
public const LOGIN_MSG_CSRFCHECKFAILED = 'csrfCheckFailed';

private IUserManager $userManager;
private IConfig $config;
Expand Down Expand Up @@ -311,7 +312,7 @@ public function tryLogin(Chain $loginChain,
$user,
$user,
$redirect_url,
$this->l10n->t('Please try again')
self::LOGIN_MSG_CSRFCHECKFAILED
);
}

Expand Down
8 changes: 8 additions & 0 deletions core/src/components/login/LoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
type="warning">
{{ t('core', 'Please contact your administrator.') }}
</NcNoteCard>
<NcNoteCard v-if="csrfCheckFailed"
:heading="t('core', 'Temporary error')"
type="error">
{{ t('core', 'Please try again.') }}
</NcNoteCard>
<NcNoteCard v-if="messages.length > 0">
<div v-for="(message, index) in messages"
:key="index">
Expand Down Expand Up @@ -186,6 +191,9 @@ export default {
apacheAuthFailed() {
return this.errors.indexOf('apacheAuthFailed') !== -1
},
csrfCheckFailed() {
return this.errors.indexOf('csrfCheckFailed') !== -1
},
internalException() {
return this.errors.indexOf('internalexception') !== -1
},
Expand Down
4 changes: 2 additions & 2 deletions dist/core-login.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-login.js.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions lib/private/Authentication/Login/LoginResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
*/
namespace OC\Authentication\Login;

use OC\Core\Controller\LoginController;

class LoginResult {
/** @var bool */
private $success;
Expand Down Expand Up @@ -59,6 +61,9 @@ public static function success(LoginData $data, ?string $redirectUrl = null) {
return $result;
}

/**
* @param LoginController::LOGIN_MSG_*|null $msg
*/
public static function failure(LoginData $data, string $msg = null): LoginResult {
$result = new static(false, $data);
if ($msg !== null) {
Expand Down
Loading