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.

23 lines
497 B

4 years ago
  1. import { writable } from "svelte/store";
  2. import { checkSession } from "../clients/amplify";
  3. function createAuthStore() {
  4. const {set, subscribe} = writable({checked: false, loggedIn: false})
  5. return {
  6. subscribe,
  7. async check() {
  8. try {
  9. const loggedIn = await checkSession();
  10. set({checked: true, loggedIn });
  11. } catch(err) {
  12. set({checked: true, loggedIn: false });
  13. }
  14. }
  15. }
  16. }
  17. const authStore = createAuthStore();
  18. export default authStore;