You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
497 B
24 lines
497 B
import { writable } from "svelte/store";
|
|
|
|
import { checkSession } from "../clients/amplify";
|
|
|
|
function createAuthStore() {
|
|
const {set, subscribe} = writable({checked: false, loggedIn: false})
|
|
|
|
return {
|
|
subscribe,
|
|
|
|
async check() {
|
|
try {
|
|
const loggedIn = await checkSession();
|
|
set({checked: true, loggedIn });
|
|
} catch(err) {
|
|
set({checked: true, loggedIn: false });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
const authStore = createAuthStore();
|
|
|
|
export default authStore;
|