Commit bf2b364e authored by Sandro Lutz's avatar Sandro Lutz Committed by lic
Browse files

Remove token parameter from url after login (Resolves #51)

parent 920c29cc
......@@ -108,26 +108,23 @@ export async function checkLogin() {
try {
const response = await m.request({
method: 'GET',
url: `${apiUrl}/sessions?where={"token":"${params.access_token}"}`,
url: `${apiUrl}/sessions/${params.access_token}`,
headers: {
Authorization: params.access_token,
},
});
if (response._items.length === 1) {
const dt2 = new Date();
session = {
userId: response._items[0].user,
token: params.access_token,
etag: response._items[0]._etag,
id: response._items[0]._id,
state: undefined,
lastChecked: dt2.getTime(),
};
saveSession();
log('User logged in!');
} else {
throw new Error({ _error: { code: 500 } });
}
const dt2 = new Date();
session = {
userId: response.user,
token: params.access_token,
etag: response._etag,
id: response._id,
state: undefined,
lastChecked: dt2.getTime(),
};
saveSession();
window.history.replaceState({}, document.title, window.location.pathname);
log('User logged in!');
} catch ({ _error: { code } }) {
session = {};
saveSession();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment