From be26c6d89a9edae76c39734531841cd3afb79b56 Mon Sep 17 00:00:00 2001
From: Mahdi
Date: Sat, 23 May 2026 13:14:44 +0330
Subject: [PATCH] Add OTP and password login with profile password setup.
Co-authored-by: Cursor
---
src/api/auth.ts | 21 +++++
src/api/types.ts | 1 +
src/components/auth/AuthModeSwitch.vue | 27 ++++++
src/views/LoginView.vue | 62 +++++++++++---
src/views/ProfileView.vue | 113 +++++++++++++++++++++----
5 files changed, 196 insertions(+), 28 deletions(-)
create mode 100644 src/components/auth/AuthModeSwitch.vue
diff --git a/src/api/auth.ts b/src/api/auth.ts
index 1483ef6..3bbf276 100644
--- a/src/api/auth.ts
+++ b/src/api/auth.ts
@@ -31,3 +31,24 @@ export function verifyOtp(mobile: string, code: string) {
export function fetchMe(token: string) {
return api('/auth/me', { token });
}
+
+export function loginWithPassword(mobile: string, password: string) {
+ return api('/auth/login-password', {
+ method: 'POST',
+ body: JSON.stringify({
+ mobile: normalizeIranMobile(mobile),
+ password,
+ }),
+ });
+}
+
+export function setPassword(payload: {
+ password: string;
+ confirmPassword: string;
+ currentPassword?: string;
+}) {
+ return api('/auth/set-password', {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ });
+}
diff --git a/src/api/types.ts b/src/api/types.ts
index a8a8023..039b66a 100644
--- a/src/api/types.ts
+++ b/src/api/types.ts
@@ -6,6 +6,7 @@ export type User = {
fullName: string | null;
role: UserRole;
isActive: boolean;
+ hasPassword?: boolean;
createdAt?: string;
updatedAt?: string;
};
diff --git a/src/components/auth/AuthModeSwitch.vue b/src/components/auth/AuthModeSwitch.vue
new file mode 100644
index 0000000..714f8aa
--- /dev/null
+++ b/src/components/auth/AuthModeSwitch.vue
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
diff --git a/src/views/LoginView.vue b/src/views/LoginView.vue
index 1cb8a17..17c9701 100644
--- a/src/views/LoginView.vue
+++ b/src/views/LoginView.vue
@@ -7,6 +7,8 @@
{{ error }}
+
+
+
+
+ اولین بار؟ با کد یکبارمصرف وارد شوید و در پروفایل رمز بسازید.
+