mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-24 07:39:41 +02:00
fix: (OAuth) redirect to direct login on failure (#3406)
Some checks failed
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Docker Nightly Production / Backend Server Tests (push) Has been cancelled
Docker Nightly Production / Frontend and End-to-End Tests (push) Has been cancelled
Docker Nightly Production / Build Tagged Release (push) Has been cancelled
Docker Nightly Production / Notify Discord (push) Has been cancelled
Some checks failed
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Docker Nightly Production / Backend Server Tests (push) Has been cancelled
Docker Nightly Production / Frontend and End-to-End Tests (push) Has been cancelled
Docker Nightly Production / Build Tagged Release (push) Has been cancelled
Docker Nightly Production / Notify Discord (push) Has been cancelled
This commit is contained in:
parent
2a3463b746
commit
f709d11952
1 changed files with 19 additions and 7 deletions
|
@ -34,6 +34,11 @@ export default class DynamicOpenIDConnectScheme extends OpenIDConnectScheme {
|
||||||
}
|
}
|
||||||
|
|
||||||
async _handleCallback() {
|
async _handleCallback() {
|
||||||
|
// sometimes the mealie token is being sent in the request to the IdP on callback which
|
||||||
|
// causes an error, so we clear it if we have one
|
||||||
|
if (this.token.get()) {
|
||||||
|
this.token.reset();
|
||||||
|
}
|
||||||
const redirect = await super._handleCallback()
|
const redirect = await super._handleCallback()
|
||||||
await this.updateAccessToken()
|
await this.updateAccessToken()
|
||||||
|
|
||||||
|
@ -49,13 +54,20 @@ export default class DynamicOpenIDConnectScheme extends OpenIDConnectScheme {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await this.$auth.requestWith(this.name, {
|
try {
|
||||||
url: "/api/auth/token",
|
const response = await this.$auth.requestWith(this.name, {
|
||||||
method: "post"
|
url: "/api/auth/token",
|
||||||
})
|
method: "post"
|
||||||
|
})
|
||||||
// Update tokens with mealie token
|
// Update tokens with mealie token
|
||||||
this.updateTokens(response)
|
this.updateTokens(response)
|
||||||
|
} catch {
|
||||||
|
const currentUrl = new URL(window.location.href)
|
||||||
|
if (currentUrl.pathname === "/login" && currentUrl.searchParams.has("direct")) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
window.location.replace("/login?direct=1")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isValidMealieToken() {
|
isValidMealieToken() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue