Просмотр исходного кода

Fix default redirect on successful WebAuthn login

Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
tags/v26.0.0beta1
Richard Steinmetz 1 год назад
Родитель
Сommit
fc4dd3041c
Аккаунт пользователя с таким Email не найден

+ 8
- 2
core/Controller/WebAuthnController.php Просмотреть файл

@@ -7,6 +7,7 @@ declare(strict_types=1);
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Richard Steinmetz <richard@steinmetz.cloud>
*
* @license GNU AGPL version 3 or any later version
*
@@ -29,6 +30,7 @@ namespace OC\Core\Controller;
use OC\Authentication\Login\LoginData;
use OC\Authentication\Login\WebAuthnChain;
use OC\Authentication\WebAuthn\Manager;
use OC\URLGenerator;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
@@ -46,14 +48,16 @@ class WebAuthnController extends Controller {
private ISession $session;
private LoggerInterface $logger;
private WebAuthnChain $webAuthnChain;
private UrlGenerator $urlGenerator;

public function __construct($appName, IRequest $request, Manager $webAuthnManger, ISession $session, LoggerInterface $logger, WebAuthnChain $webAuthnChain) {
public function __construct($appName, IRequest $request, Manager $webAuthnManger, ISession $session, LoggerInterface $logger, WebAuthnChain $webAuthnChain, URLGenerator $urlGenerator) {
parent::__construct($appName, $request);

$this->webAuthnManger = $webAuthnManger;
$this->session = $session;
$this->logger = $logger;
$this->webAuthnChain = $webAuthnChain;
$this->urlGenerator = $urlGenerator;
}

/**
@@ -106,6 +110,8 @@ class WebAuthnController extends Controller {
);
$this->webAuthnChain->process($loginData);

return new JSONResponse([]);
return new JSONResponse([
'defaultRedirectUrl' => $this->urlGenerator->linkToDefaultPageUrl(),
]);
}
}

+ 4
- 3
core/src/components/login/PasswordLessLoginForm.vue Просмотреть файл

@@ -200,12 +200,13 @@ export default {
completeAuthentication(challenge) {
console.debug('TIME TO COMPLETE')

const location = this.redirectUrl
const redirectUrl = this.redirectUrl

return finishAuthentication(JSON.stringify(challenge))
.then(data => {
.then(({ defaultRedirectUrl }) => {
console.debug('Logged in redirecting')
window.location.href = location
// Redirect url might be false so || should be used instead of ??.
window.location.href = redirectUrl || defaultRedirectUrl
})
.catch(error => {
console.debug('GOT AN ERROR WHILE SUBMITTING CHALLENGE!')

+ 2
- 2
dist/core-login.js
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 1
- 1
dist/core-login.js.map
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


Загрузка…
Отмена
Сохранить