diff --git a/backend/app/routers/auth.py b/backend/app/routers/auth.py index 56db188..96dba62 100644 --- a/backend/app/routers/auth.py +++ b/backend/app/routers/auth.py @@ -31,7 +31,6 @@ router = APIRouter(prefix="/auth", tags=["auth"]) class LoginRequest(BaseModel): username: str password: str - organization: str | None = None # optional override; defaults to CASDOOR_ORGANIZATION @router.post("/login") diff --git a/docs/casdoor-auth.md b/docs/casdoor-auth.md index 39abae1..914a5ad 100644 --- a/docs/casdoor-auth.md +++ b/docs/casdoor-auth.md @@ -35,7 +35,7 @@ to re-run). ## 2. Login flow (in-page, no redirect) ``` -Browser ──► POST /api/v1/auth/login {username, password, organization?} +Browser ──► POST /api/v1/auth/login {username, password} │ ▼ Backend ──► POST http://casdoor:8000/api/login/oauth/access_token diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index 796a15e..b52bfde 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -1460,7 +1460,6 @@ export const apiV26 = { login: async (body: { username: string; password: string; - organization?: string; }): Promise<{ access_token: string; expires_in: number | null; user: import("../store/auth").AuthUser }> => { const res = await request<{ data: { diff --git a/frontend/src/pages/Auth/LoginPage.tsx b/frontend/src/pages/Auth/LoginPage.tsx index 9331c9a..548fcb8 100644 --- a/frontend/src/pages/Auth/LoginPage.tsx +++ b/frontend/src/pages/Auth/LoginPage.tsx @@ -1,14 +1,14 @@ import { useEffect, useMemo, useState } from "react"; import { useNavigate } from "react-router-dom"; import { toast } from "sonner"; -import { ClipboardList, Loader2, Lock, ShieldCheck, Wrench, X } from "lucide-react"; +import { ClipboardList, Eye, EyeOff, Loader2, Lock, ShieldCheck, Wrench, X } from "lucide-react"; import { api, apiV26 } from "../../lib/api"; import { useAuthStore } from "../../store/auth"; import type { Project } from "../../lib/types"; // ============================================================ // ورود به سامانه — Casdoor درون‌صفحه‌ای (بدون ریدایرکت) -// فرم اصلی: Username / Password / Organization (اختیاری) → +// فرم اصلی: Username / Password → // POST /api/v1/auth/login (بک‌اند با grant_type=password از // Casdoor توکن می‌گیرد و نقش را از جدول users خودمان برمی‌گرداند) // حالت توسعه (فقط ادمین — سوپر یوزر) — چرخه‌ی ۳ مرحله‌ای: @@ -36,7 +36,7 @@ export function LoginPage() { // ---- فرم اصلی (Casdoor) ---- const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); - const [organization, setOrganization] = useState(""); + const [showPassword, setShowPassword] = useState(false); const [loading, setLoading] = useState(false); // ---- پنل حالت توسعه (۳ مرحله) ---- @@ -71,7 +71,6 @@ export function LoginPage() { const { access_token, user } = await apiV26.auth.login({ username: username.trim(), password, - ...(organization.trim() ? { organization: organization.trim() } : {}), }); if (!user.role) { toast.error("نقش شما هنوز در سیستم تعیین نشده است — با مدیر سیستم تماس بگیرید"); @@ -101,7 +100,6 @@ export function LoginPage() { const { user: adminUser } = await apiV26.auth.login({ username: devAdminUser.trim(), password: devAdminPass, - ...(organization.trim() ? { organization: organization.trim() } : {}), }); if (adminUser.role !== "admin") { toast.error("حالت توسعه فقط برای ادمین (سوپر یوزر) در دسترس است"); @@ -298,30 +296,33 @@ export function LoginPage() { - setPassword(e.target.value)} - /> - -
- - setOrganization(e.target.value)} - /> +
+ setPassword(e.target.value)} + /> + +