Skip to content
Snippets Groups Projects
authStore.js 636 B
import { defineStore } from "pinia";
export const useAuthStore = defineStore("auth", {
  state: () => {
    return {
      token: "",
      account: {},
      profile: {},
      profiles: []
    };
  },
  persist: {
    storage: localStorage
  },
  getters: {
    isLoggedIn() {
      return this.token.length > 0
    }
  },
  actions: {
    setToken(token) {
      this.token = token;
    },
    setAccount(account) {
      this.account = account;
    },
    logout() {
      this.$reset();
    },
    setProfile(profile) {
      this.profile = profile;
    },
    setProfiles(profiles) {
      this.profiles = profiles;
    }
  }
});