mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 11:16:35 +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();
|
const data = await response.json();
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
|
// allow auth provider bypass the login form
|
||||||
|
if (data.type === "create_entry") {
|
||||||
|
this._redirect(data.result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._updateStep(data);
|
this._updateStep(data);
|
||||||
} else {
|
} else {
|
||||||
this.setProperties({
|
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) {
|
_updateStep(step) {
|
||||||
const props = {
|
const props = {
|
||||||
_step: step,
|
_step: step,
|
||||||
@ -229,21 +253,7 @@ class HaAuthFlow extends localizeLiteMixin(PolymerElement) {
|
|||||||
const newStep = await response.json();
|
const newStep = await response.json();
|
||||||
|
|
||||||
if (newStep.type === "create_entry") {
|
if (newStep.type === "create_entry") {
|
||||||
// OAuth 2: 3.1.2 we need to retain query component of a redirect URI
|
this._redirect(newStep.result);
|
||||||
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;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._updateStep(newStep);
|
this._updateStep(newStep);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user