Merge pull request #40799 from nextcloud/fix/login-csrf-check-error-message

fix: Show error message when CSRF check fails at login
This commit is contained in:
Christoph Wurst 2023-11-08 16:33:53 +01:00 committed by GitHub
commit d751baee36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 4 deletions

View file

@ -64,6 +64,7 @@ use OCP\Util;
class LoginController extends Controller {
public const LOGIN_MSG_INVALIDPASSWORD = 'invalidpassword';
public const LOGIN_MSG_USERDISABLED = 'userdisabled';
public const LOGIN_MSG_CSRFCHECKFAILED = 'csrfCheckFailed';
public function __construct(
?string $appName,
@ -291,7 +292,7 @@ class LoginController extends Controller {
$user,
$user,
$redirect_url,
$this->l10n->t('Please try again')
self::LOGIN_MSG_CSRFCHECKFAILED
);
}

View file

@ -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">
@ -184,6 +189,9 @@ export default {
apacheAuthFailed() {
return this.errors.indexOf('apacheAuthFailed') !== -1
},
csrfCheckFailed() {
return this.errors.indexOf('csrfCheckFailed') !== -1
},
internalException() {
return this.errors.indexOf('internalexception') !== -1
},

4
dist/core-login.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -25,6 +25,8 @@ declare(strict_types=1);
*/
namespace OC\Authentication\Login;
use OC\Core\Controller\LoginController;
class LoginResult {
/** @var bool */
private $success;
@ -59,6 +61,9 @@ class LoginResult {
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) {