mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 01:36:49 +00:00
Allow auth provider bypass login form (#3025)
This commit is contained in:
parent
44eaa3abad
commit
5080f4c2db
@ -121,6 +121,12 @@ class HaAuthFlow extends localizeLiteMixin(PolymerElement) {
|
||||
const data = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
// allow auth provider bypass the login form
|
||||
if (data.type === "create_entry") {
|
||||
this._redirect(data.result);
|
||||
return;
|
||||
}
|
||||
|
||||
this._updateStep(data);
|
||||
} else {
|
||||
this.setProperties({
|
||||
@ -138,6 +144,24 @@ class HaAuthFlow extends localizeLiteMixin(PolymerElement) {
|
||||
}
|
||||
}
|
||||
|
||||
_redirect(authCode) {
|
||||
// OAuth 2: 3.1.2 we need to retain query component of a redirect URI
|
||||
let url = this.redirectUri;
|
||||
if (!url.includes("?")) {
|
||||
url += "?";
|
||||
} else if (!url.endsWith("&")) {
|
||||
url += "&";
|
||||
}
|
||||
|
||||
url += `code=${encodeURIComponent(authCode)}`;
|
||||
|
||||
if (this.oauth2State) {
|
||||
url += `&state=${encodeURIComponent(this.oauth2State)}`;
|
||||
}
|
||||
|
||||
document.location = url;
|
||||
}
|
||||
|
||||
_updateStep(step) {
|
||||
const props = {
|
||||
_step: step,
|
||||
@ -229,21 +253,7 @@ class HaAuthFlow extends localizeLiteMixin(PolymerElement) {
|
||||
const newStep = await response.json();
|
||||
|
||||
if (newStep.type === "create_entry") {
|
||||
// OAuth 2: 3.1.2 we need to retain query component of a redirect URI
|
||||
let url = this.redirectUri;
|
||||
if (!url.includes("?")) {
|
||||
url += "?";
|
||||
} else if (!url.endsWith("&")) {
|
||||
url += "&";
|
||||
}
|
||||
|
||||
url += `code=${encodeURIComponent(newStep.result)}`;
|
||||
|
||||
if (this.oauth2State) {
|
||||
url += `&state=${encodeURIComponent(this.oauth2State)}`;
|
||||
}
|
||||
|
||||
document.location = url;
|
||||
this._redirect(newStep.result);
|
||||
return;
|
||||
}
|
||||
this._updateStep(newStep);
|
||||
|
Loading…
x
Reference in New Issue
Block a user