blob: 47ac94c19d1c98486e3ab0520f32a383d32a237e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import { remote } from 'electron';
import localStorage from 'mobx-localstorage';
const { app } = remote;
export const prepareAuthRequest = (options, auth = true) => {
const request = Object.assign(options, {
mode: 'cors',
headers: Object.assign({
'Content-Type': 'application/json',
'X-Franz-Source': 'desktop',
'X-Franz-Version': app.getVersion(),
'X-Franz-platform': process.platform,
'X-Franz-Timezone-Offset': new Date().getTimezoneOffset(),
'X-Franz-System-Locale': app.getLocale(),
}, options.headers),
});
if (auth) {
request.headers.Authorization = `Bearer ${localStorage.getItem('authToken')}`;
}
return request;
};
|