mirror of
https://github.com/simple-login/app.git
synced 2024-11-10 21:27:10 +01:00
Add to static js also the headers (#2153)
* Add to static js also the headers * Move all header generation to a function
This commit is contained in:
parent
e0d4ee9f8c
commit
1482bb4a33
@ -51,14 +51,19 @@ $(".enable-disable-alias").change(async function () {
|
|||||||
await disableAlias(aliasId, alias);
|
await disableAlias(aliasId, alias);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function getHeaders() {
|
||||||
|
return {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-Sl-Allowcookies": 'allow',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function disableAlias(aliasId, alias) {
|
async function disableAlias(aliasId, alias) {
|
||||||
let oldValue;
|
let oldValue;
|
||||||
try {
|
try {
|
||||||
let res = await fetch(`/api/aliases/${aliasId}/toggle`, {
|
let res = await fetch(`/api/aliases/${aliasId}/toggle`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: getHeaders()
|
||||||
"Content-Type": "application/json",
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
@ -94,9 +99,7 @@ $(".enable-disable-pgp").change(async function (e) {
|
|||||||
try {
|
try {
|
||||||
let res = await fetch(`/api/aliases/${aliasId}`, {
|
let res = await fetch(`/api/aliases/${aliasId}`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
headers: {
|
headers: getHeaders(),
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
disable_pgp: oldValue,
|
disable_pgp: oldValue,
|
||||||
}),
|
}),
|
||||||
@ -129,9 +132,7 @@ $(".pin-alias").change(async function () {
|
|||||||
try {
|
try {
|
||||||
let res = await fetch(`/api/aliases/${aliasId}`, {
|
let res = await fetch(`/api/aliases/${aliasId}`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
headers: {
|
headers: getHeaders(),
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
pinned: newValue,
|
pinned: newValue,
|
||||||
}),
|
}),
|
||||||
@ -161,9 +162,7 @@ async function handleNoteChange(aliasId, aliasEmail) {
|
|||||||
try {
|
try {
|
||||||
let res = await fetch(`/api/aliases/${aliasId}`, {
|
let res = await fetch(`/api/aliases/${aliasId}`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
headers: {
|
headers: getHeaders(),
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
note: note,
|
note: note,
|
||||||
}),
|
}),
|
||||||
@ -200,9 +199,7 @@ async function handleMailboxChange(aliasId, aliasEmail) {
|
|||||||
try {
|
try {
|
||||||
let res = await fetch(`/api/aliases/${aliasId}`, {
|
let res = await fetch(`/api/aliases/${aliasId}`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
headers: {
|
headers: getHeaders(),
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
mailbox_ids: mailbox_ids,
|
mailbox_ids: mailbox_ids,
|
||||||
}),
|
}),
|
||||||
@ -225,9 +222,7 @@ async function handleDisplayNameChange(aliasId, aliasEmail) {
|
|||||||
try {
|
try {
|
||||||
let res = await fetch(`/api/aliases/${aliasId}`, {
|
let res = await fetch(`/api/aliases/${aliasId}`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
headers: {
|
headers: getHeaders(),
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
name: name,
|
name: name,
|
||||||
}),
|
}),
|
||||||
|
Loading…
Reference in New Issue
Block a user