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.
 
 
 
 
 

30 lines
746 B

export const useAuthStore = defineStore('Auth', () => {
const requiresPassword = ref<boolean>(true);
/**
* @throws if unsuccessful
*/
async function login(password: string, remember: boolean) {
const response = await api.createSession({ password, remember });
requiresPassword.value = response.requiresPassword;
return true as const;
}
/**
* @throws if unsuccessful
*/
async function logout() {
const response = await api.deleteSession();
return response.success;
}
/**
* @throws if unsuccessful
*/
async function update() {
const session = await api.getSession();
requiresPassword.value = session.requiresPassword;
}
return { requiresPassword, login, logout, update };
});