svelte-migrate: updated files
This commit is contained in:
parent
4d6149760d
commit
ff5a2eef65
36 changed files with 1252 additions and 1384 deletions
|
|
@ -8,14 +8,10 @@ function createUserStore() {
|
|||
set: (auth) => {
|
||||
update((m) => auth);
|
||||
},
|
||||
update: (res_auth, cb=null) => {
|
||||
update: (res_auth) => {
|
||||
if (res_auth.status === 200) {
|
||||
res_auth.json().then((auth) => {
|
||||
update((m) => (Object.assign(m?m:{}, auth)));
|
||||
|
||||
if (cb) {
|
||||
cb(my);
|
||||
}
|
||||
});
|
||||
} else if (res_auth.status >= 400 && res_auth.status < 500) {
|
||||
update((m) => (null));
|
||||
|
|
@ -24,4 +20,14 @@ function createUserStore() {
|
|||
};
|
||||
}
|
||||
|
||||
export async function refresh_auth() {
|
||||
const res = await fetch('api/auth', {headers: {'Accept': 'application/json'}})
|
||||
if (res.status == 200) {
|
||||
const auth = await res.json();
|
||||
user.set(auth);
|
||||
} else {
|
||||
user.set(null);
|
||||
}
|
||||
}
|
||||
|
||||
export const user = createUserStore();
|
||||
|
|
|
|||
Reference in a new issue