revert pramod changed - (tenant login mistake

This commit is contained in:
Kartik Sharma 2025-09-21 16:58:29 +05:30
parent 7e6020e3db
commit aee510f527
2 changed files with 18 additions and 37 deletions

View File

@ -6,7 +6,7 @@ import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { z } from "zod";
import { AuthWrapper } from "./AuthWrapper";
import { setOrgToken } from "../../services/tenantService";
const LoginPage = () => {
const navigate = useNavigate();
const [loading, setLoading] = useState(false);
@ -41,11 +41,10 @@ const LoginPage = () => {
password: data.password,
};
const response = await AuthRepository.login(userCredential);
// localStorage.setItem("jwtToken", response.data.token);
// localStorage.setItem("refreshToken", response.data.refreshToken);
localStorage.setItem("jwtToken", response.data.token);
localStorage.setItem("refreshToken", response.data.refreshToken);
setLoading(false);
setOrgToken(response.data.token, response.data.refreshToken);
navigate("/auth/user");
navigate("/dashboard");
} else {
await AuthRepository.sendOTP({ email: data.username });
showToast("OTP has been sent to your email.", "success");
@ -147,8 +146,7 @@ const LoginPage = () => {
type={hidepass ? "password" : "text"}
autoComplete="new-password"
id="password"
className={`form-control form-control-xl shadow-none ${
errors.password ? "is-invalid" : ""
className={`form-control form-control-xl shadow-none ${errors.password ? "is-invalid" : ""
}`}
name="password"
{...register("password")}
@ -172,15 +170,13 @@ const LoginPage = () => {
{/* ✅ Error message */}
{errors.password && (
<div
className="invalid-feedback text-start"
style={{ fontSize: "12px" }}
>
<div className="invalid-feedback text-start" style={{ fontSize: "12px" }}>
{errors.password.message}
</div>
)}
</div>
{/* Remember Me + Forgot Password */}
<div className="mb-3 d-flex justify-content-between align-items-center">
<div className="form-check">

View File

@ -15,23 +15,8 @@ const AuthRepository = {
logout: (data) => api.post("/api/auth/logout", data),
profile: () => api.get("/api/user/profile"),
changepassword: (data) => api.post("/api/auth/change-password", data),
appmenu: () => api.get("/api/appmenu/get/menu"),
// getTenantList: () =>
// api.get("/api/Auth/get/user/tenants", {}, { useTenantToken: false }),
// selectTenant: (tenantId) =>
// api.post(`/api/Auth/select-tenant/${tenantId}`),
appmenu:()=>api.get('/api/appmenu/get/menu')
// ---------------- Org-level routes (use org token) ---------------
// Note: pass `orgToken: true` (4th arg) so axios interceptor uses orgJwtToken.
getTenantList: () => api.get("/api/Auth/get/user/tenants", {}, {}, true),
// Exchange tenantId (with org token) -> server returns tenant JWT
// Using POST with body { tenantId } (adjust if your API expects path param).
selectTenant: (tenantId) =>
api.post("/api/Auth/select-tenant", { tenantId }, {}, true),
// If your backend expects tenantId in URL instead of body, use this variant:
// selectTenant: (tenantId) => api.post(`/api/Auth/select-tenant/${tenantId}`, {}, {}, true),
};
export default AuthRepository;