Skip to content

Commit

Permalink
Signin if can't restore session
Browse files Browse the repository at this point in the history
PR-URL: #81
  • Loading branch information
tshemsedinov committed Feb 4, 2021
1 parent 6fcbd56 commit 43ecbce
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions application/static/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,12 @@ window.addEventListener('load', async () => {
window.api = window.application.metacom.api;
await application.metacom.load('auth', 'console', 'example');
const token = localStorage.getItem('metarhia.session.token');
let logged = false;
if (token) {
await api.auth.restore({ token });
} else {
const res = await api.auth.restore({ token });
logged = res.status === 'logged';
}
if (!logged) {
const res = await api.auth.signin({ login: 'marcus', password: 'marcus' });
if (res.token) {
localStorage.setItem('metarhia.session.token', res.token);
Expand Down

0 comments on commit 43ecbce

Please sign in to comment.