svelte-migrate: updated files

This commit is contained in:
nemunaire 2022-12-12 10:24:30 +01:00
commit ff5a2eef65
36 changed files with 1252 additions and 1384 deletions

View file

@ -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();