mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 19:26:36 +00:00
allow 'same-origin' credentials for fetch() (#1530)
This commit is contained in:
parent
db310646b7
commit
cc652a9476
@ -72,6 +72,7 @@ class HaAuthFlow extends EventsMixin(PolymerElement) {
|
|||||||
|
|
||||||
fetch('/auth/login_flow', {
|
fetch('/auth/login_flow', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
credentials: 'same-origin',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
client_id: this.clientId,
|
client_id: this.clientId,
|
||||||
handler: [this.authProvider.type, this.authProvider.id],
|
handler: [this.authProvider.type, this.authProvider.id],
|
||||||
@ -111,6 +112,7 @@ class HaAuthFlow extends EventsMixin(PolymerElement) {
|
|||||||
|
|
||||||
fetch(`/auth/login_flow/${this._step.flow_id}`, {
|
fetch(`/auth/login_flow/${this._step.flow_id}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
credentials: 'same-origin',
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
if (!response.ok) throw new Error();
|
if (!response.ok) throw new Error();
|
||||||
|
@ -53,7 +53,7 @@ class HaPickAuthProvider extends EventsMixin(PolymerElement) {
|
|||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
|
|
||||||
fetch('/auth/providers').then((response) => {
|
fetch('/auth/providers', { credentials: 'same-origin' }).then((response) => {
|
||||||
if (!response.ok) throw new Error();
|
if (!response.ok) throw new Error();
|
||||||
return response.json();
|
return response.json();
|
||||||
}).then((authProviders) => {
|
}).then((authProviders) => {
|
||||||
|
@ -4,6 +4,7 @@ export default function fetchToken(clientId, code) {
|
|||||||
data.append('grant_type', 'authorization_code');
|
data.append('grant_type', 'authorization_code');
|
||||||
data.append('code', code);
|
data.append('code', code);
|
||||||
return fetch('/auth/token', {
|
return fetch('/auth/token', {
|
||||||
|
credentials: 'same-origin',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: data,
|
body: data,
|
||||||
}).then((resp) => {
|
}).then((resp) => {
|
||||||
|
@ -4,6 +4,7 @@ export default function refreshAccessToken(clientId, refreshToken) {
|
|||||||
data.append('grant_type', 'refresh_token');
|
data.append('grant_type', 'refresh_token');
|
||||||
data.append('refresh_token', refreshToken);
|
data.append('refresh_token', refreshToken);
|
||||||
return fetch('/auth/token', {
|
return fetch('/auth/token', {
|
||||||
|
credentials: 'same-origin',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: data,
|
body: data,
|
||||||
}).then((resp) => {
|
}).then((resp) => {
|
||||||
|
@ -41,6 +41,7 @@ function initPushNotifications() {
|
|||||||
delete payload.data;
|
delete payload.data;
|
||||||
}
|
}
|
||||||
fetch('/api/notify.html5/callback', {
|
fetch('/api/notify.html5/callback', {
|
||||||
|
credentials: 'same-origin',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: new Headers({ 'Content-Type': 'application/json',
|
headers: new Headers({ 'Content-Type': 'application/json',
|
||||||
Authorization: 'Bearer ' + jwt }),
|
Authorization: 'Bearer ' + jwt }),
|
||||||
|
@ -80,7 +80,7 @@ export function getTranslation(fragment, translationInput) {
|
|||||||
// Create a promise to fetch translation from the server
|
// Create a promise to fetch translation from the server
|
||||||
if (!translations[translationFingerprint]) {
|
if (!translations[translationFingerprint]) {
|
||||||
translations[translationFingerprint] =
|
translations[translationFingerprint] =
|
||||||
fetch(`/static/translations/${translationFingerprint}`, { credentials: 'include' })
|
fetch(`/static/translations/${translationFingerprint}`, { credentials: 'same-origin' })
|
||||||
.then(response => response.json()).then(data => ({
|
.then(response => response.json()).then(data => ({
|
||||||
language: translation,
|
language: translation,
|
||||||
data: data,
|
data: data,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user