aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/utils/auth.js
diff options
context:
space:
mode:
authorLibravatar Markus Hatvan <markus_hatvan@aon.at>2021-10-02 09:24:32 +0200
committerLibravatar GitHub <noreply@github.com>2021-10-02 09:24:32 +0200
commitbfe8847d72cd0893230f2e654242658214943e61 (patch)
tree3384b02ebad7a74cbb106ddd95546e0e24ff0bb8 /src/api/utils/auth.js
parentfix: Fix navigation shortcut accelerator for non-macos (fixes #1172) (#2012) (diff)
downloadferdium-app-bfe8847d72cd0893230f2e654242658214943e61.tar.gz
ferdium-app-bfe8847d72cd0893230f2e654242658214943e61.tar.zst
ferdium-app-bfe8847d72cd0893230f2e654242658214943e61.zip
chore: convert various files from JS to TS (#2010)
Diffstat (limited to 'src/api/utils/auth.js')
-rw-r--r--src/api/utils/auth.js32
1 files changed, 0 insertions, 32 deletions
diff --git a/src/api/utils/auth.js b/src/api/utils/auth.js
deleted file mode 100644
index 07b0c096b..000000000
--- a/src/api/utils/auth.js
+++ /dev/null
@@ -1,32 +0,0 @@
1import localStorage from 'mobx-localstorage';
2import { ferdiLocale, ferdiVersion } from '../../environment-remote';
3
4export const prepareAuthRequest = (
5 // eslint-disable-next-line unicorn/no-object-as-default-parameter
6 options = { method: 'GET' },
7 auth = true,
8) => {
9 const request = Object.assign(options, {
10 mode: 'cors',
11 headers: {
12 'Content-Type': 'application/json',
13 'X-Franz-Source': 'desktop',
14 'X-Franz-Version': ferdiVersion,
15 'X-Franz-platform': process.platform,
16 'X-Franz-Timezone-Offset': new Date().getTimezoneOffset(),
17 'X-Franz-System-Locale': ferdiLocale,
18 ...options.headers,
19 },
20 });
21
22 if (auth) {
23 request.headers.Authorization = `Bearer ${localStorage.getItem(
24 'authToken',
25 )}`;
26 }
27
28 return request;
29};
30
31export const sendAuthRequest = (url, options, auth) =>
32 window.fetch(url, prepareAuthRequest(options, auth));