Redesign login/register with Mento branding and email/mobile OTP.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+42
-13
@@ -1,6 +1,12 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { computed, ref } from 'vue';
|
||||
import type { AuthUserDto, LoginResponse } from '@mento/shared';
|
||||
import type {
|
||||
AuthUserDto,
|
||||
LoginChallengeResponse,
|
||||
LoginResponse,
|
||||
RegisterChallengeResponse,
|
||||
RegisterOrganizationRequest,
|
||||
} from '@mento/shared';
|
||||
import { api } from '@/lib/api';
|
||||
|
||||
const TOKEN_KEY = 'mento_token';
|
||||
@@ -39,19 +45,40 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
clearLegacy();
|
||||
}
|
||||
|
||||
async function login(email: string, password: string) {
|
||||
const { data } = await api.post<LoginResponse>('/auth/login', { email, password });
|
||||
async function startLogin(identifier: string, password: string) {
|
||||
const { data } = await api.post<LoginChallengeResponse>('/auth/login', {
|
||||
identifier,
|
||||
password,
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
async function verifyLogin(challengeId: string, code: string) {
|
||||
const { data } = await api.post<LoginResponse>('/auth/login/verify', {
|
||||
challengeId,
|
||||
code,
|
||||
});
|
||||
persist(data);
|
||||
}
|
||||
|
||||
async function register(payload: {
|
||||
organizationName: string;
|
||||
fullName: string;
|
||||
email: string;
|
||||
password: string;
|
||||
businessField: string;
|
||||
}) {
|
||||
const { data } = await api.post<LoginResponse>('/auth/register', payload);
|
||||
async function startRegister(payload: RegisterOrganizationRequest) {
|
||||
const { data } = await api.post<RegisterChallengeResponse>(
|
||||
'/auth/register',
|
||||
payload,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async function verifyRegister(
|
||||
challengeId: string,
|
||||
emailCode: string,
|
||||
mobileCode: string,
|
||||
) {
|
||||
const { data } = await api.post<LoginResponse>('/auth/register/verify', {
|
||||
challengeId,
|
||||
emailCode,
|
||||
mobileCode,
|
||||
});
|
||||
persist(data);
|
||||
}
|
||||
|
||||
@@ -67,8 +94,10 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
token,
|
||||
user,
|
||||
isAuthenticated,
|
||||
login,
|
||||
register,
|
||||
startLogin,
|
||||
verifyLogin,
|
||||
startRegister,
|
||||
verifyRegister,
|
||||
logout,
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user