new funcionality
This commit is contained in:
@@ -48,8 +48,21 @@ export const useAuthStore = defineStore('auth', {
|
||||
}
|
||||
},
|
||||
|
||||
async login(payload: Credentials): Promise<string | null> {
|
||||
const { data } = await axios.post<{ user: User; intended: string | null }>('/web-api/login', payload);
|
||||
async login(payload: Credentials): Promise<{ twoFactor: true } | { twoFactor: false; intended: string | null }> {
|
||||
const { data } = await axios.post<{ two_factor?: true; user?: User; intended?: string | null }>('/web-api/login', payload);
|
||||
|
||||
if (data.two_factor) {
|
||||
return { twoFactor: true };
|
||||
}
|
||||
|
||||
this.user = data.user!;
|
||||
this.checked = true;
|
||||
|
||||
return { twoFactor: false, intended: data.intended ?? null };
|
||||
},
|
||||
|
||||
async loginTwoFactor(code: string): Promise<string | null> {
|
||||
const { data } = await axios.post<{ user: User; intended: string | null }>('/web-api/login/2fa', { code });
|
||||
this.user = data.user;
|
||||
this.checked = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user