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