stash
This commit is contained in:
parent
5c073c3049
commit
49a063f2a7
2 changed files with 3 additions and 9 deletions
|
@ -34,7 +34,7 @@ const router = createRouter({
|
||||||
routes, // short for `routes: routes`
|
routes, // short for `routes: routes`
|
||||||
})
|
})
|
||||||
|
|
||||||
router.beforeEach((to, from) => {
|
router.beforeEach((to/*, from*/) => {
|
||||||
// instead of having to check every route record with
|
// instead of having to check every route record with
|
||||||
// to.matched.some(record => record.meta.requiresAuth)
|
// to.matched.some(record => record.meta.requiresAuth)
|
||||||
if (to.meta.requiresAuth && !store.getters.isLoggedIn) {
|
if (to.meta.requiresAuth && !store.getters.isLoggedIn) {
|
||||||
|
|
|
@ -102,16 +102,10 @@ export default createStore({
|
||||||
body: JSON.stringify({username: username, password: password}),
|
body: JSON.stringify({username: username, password: password}),
|
||||||
credentials: 'omit'
|
credentials: 'omit'
|
||||||
}).then(r => r.json())
|
}).then(r => r.json())
|
||||||
if (data.token) {
|
if (data.token && data.key) {
|
||||||
commit('setToken', data.token);
|
commit('setToken', data.token);
|
||||||
commit('setUser', username);
|
commit('setUser', username);
|
||||||
const j = await fetch('/auth/keys/', {
|
commit('setKey', data.key);
|
||||||
method: 'GET',
|
|
||||||
headers: {'Authorization': 'Token ' + data.token},
|
|
||||||
credentials: 'omit'
|
|
||||||
}).then(r => r.json())
|
|
||||||
const k = j.key
|
|
||||||
commit('setKey', k)
|
|
||||||
const s = await dispatch('lookupServer', {username}).then(servers => new ServerSet(servers, state.unreachable_neighbors))
|
const s = await dispatch('lookupServer', {username}).then(servers => new ServerSet(servers, state.unreachable_neighbors))
|
||||||
commit('setHomeServers', s)
|
commit('setHomeServers', s)
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue