parent
d2a4e50669
commit
c9eae00c8c
1 changed files with 2 additions and 14 deletions
|
@ -9,18 +9,6 @@ const uri = require('./util/uri.js');
|
||||||
let fileTokens = {};
|
let fileTokens = {};
|
||||||
let remoteConfig = null;
|
let remoteConfig = null;
|
||||||
|
|
||||||
function getCookieName() {
|
|
||||||
const bases = document.getElementsByTagName('base');
|
|
||||||
if (bases.length) {
|
|
||||||
let baseHref = bases[0].href;
|
|
||||||
baseHref = baseHref.replace('/', '');
|
|
||||||
return 'szuru-' + baseHref;
|
|
||||||
} else {
|
|
||||||
return 'szuru';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const cookieName = getCookieName();
|
|
||||||
|
|
||||||
class Api extends events.EventTarget {
|
class Api extends events.EventTarget {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
@ -138,7 +126,7 @@ class Api extends events.EventTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
loginFromCookies() {
|
loginFromCookies() {
|
||||||
const auth = cookies.getJSON(cookieName);
|
const auth = cookies.getJSON('auth');
|
||||||
return auth && auth.user && auth.token ?
|
return auth && auth.user && auth.token ?
|
||||||
this.loginWithToken(auth.user, auth.token, true) :
|
this.loginWithToken(auth.user, auth.token, true) :
|
||||||
Promise.resolve();
|
Promise.resolve();
|
||||||
|
@ -181,7 +169,7 @@ class Api extends events.EventTarget {
|
||||||
this.post('/user-token/' + userName, userTokenRequest)
|
this.post('/user-token/' + userName, userTokenRequest)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
cookies.set(
|
cookies.set(
|
||||||
cookieName,
|
'auth',
|
||||||
{'user': userName, 'token': response.token},
|
{'user': userName, 'token': response.token},
|
||||||
options);
|
options);
|
||||||
this.userName = userName;
|
this.userName = userName;
|
||||||
|
|
Loading…
Reference in a new issue