Use password login without OTP; keep OTP for signup and optional mobile login.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -45,16 +45,23 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
clearLegacy();
|
||||
}
|
||||
|
||||
async function startLogin(identifier: string, password: string) {
|
||||
const { data } = await api.post<LoginChallengeResponse>('/auth/login', {
|
||||
async function login(identifier: string, password: string) {
|
||||
const { data } = await api.post<LoginResponse>('/auth/login', {
|
||||
identifier,
|
||||
password,
|
||||
});
|
||||
persist(data);
|
||||
}
|
||||
|
||||
async function requestLoginOtp(mobile: string) {
|
||||
const { data } = await api.post<LoginChallengeResponse>('/auth/login/otp', {
|
||||
mobile,
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
async function verifyLogin(challengeId: string, code: string) {
|
||||
const { data } = await api.post<LoginResponse>('/auth/login/verify', {
|
||||
async function verifyLoginOtp(challengeId: string, code: string) {
|
||||
const { data } = await api.post<LoginResponse>('/auth/login/otp/verify', {
|
||||
challengeId,
|
||||
code,
|
||||
});
|
||||
@@ -71,13 +78,13 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
|
||||
async function verifyRegister(
|
||||
challengeId: string,
|
||||
emailCode: string,
|
||||
mobileCode: string,
|
||||
emailCode?: string,
|
||||
) {
|
||||
const { data } = await api.post<LoginResponse>('/auth/register/verify', {
|
||||
challengeId,
|
||||
emailCode,
|
||||
mobileCode,
|
||||
...(emailCode ? { emailCode } : {}),
|
||||
});
|
||||
persist(data);
|
||||
}
|
||||
@@ -94,8 +101,9 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
token,
|
||||
user,
|
||||
isAuthenticated,
|
||||
startLogin,
|
||||
verifyLogin,
|
||||
login,
|
||||
requestLoginOtp,
|
||||
verifyLoginOtp,
|
||||
startRegister,
|
||||
verifyRegister,
|
||||
logout,
|
||||
|
||||
Reference in New Issue
Block a user