mirror of https://github.com/wg-easy/wg-easy
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.
32 lines
759 B
32 lines
759 B
export const useAuthStore = defineStore('Auth', () => {
|
|
/**
|
|
* @throws if unsuccessful
|
|
*/
|
|
async function signup(username: string, password: string) {
|
|
const response = await api.setupAccount({ username, password });
|
|
return response.success;
|
|
}
|
|
|
|
/**
|
|
* @throws if unsuccessful
|
|
*/
|
|
async function login(username: string, password: string, remember: boolean) {
|
|
await api.createSession({ username, password, remember });
|
|
return true as const;
|
|
}
|
|
|
|
/**
|
|
* @throws if unsuccessful
|
|
*/
|
|
async function logout() {
|
|
const response = await api.deleteSession();
|
|
return response.success;
|
|
}
|
|
|
|
async function update() {
|
|
// store role etc
|
|
await api.getSession();
|
|
}
|
|
|
|
return { login, logout, update, signup };
|
|
});
|
|
|