revert pramod changed - (tenant login mistake
This commit is contained in:
parent
7e6020e3db
commit
aee510f527
@ -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);
|
||||
@ -16,13 +16,13 @@ const LoginPage = () => {
|
||||
|
||||
const loginSchema = IsLoginWithOTP
|
||||
? z.object({
|
||||
username: z.string().trim().email({ message: "Valid email required" }),
|
||||
})
|
||||
username: z.string().trim().email({ message: "Valid email required" }),
|
||||
})
|
||||
: z.object({
|
||||
username: z.string().trim().email({ message: "Valid email required" }),
|
||||
password: z.string().trim().min(1, { message: "Password required" }),
|
||||
rememberMe: z.boolean(),
|
||||
});
|
||||
username: z.string().trim().email({ message: "Valid email required" }),
|
||||
password: z.string().trim().min(1, { message: "Password required" }),
|
||||
rememberMe: z.boolean(),
|
||||
});
|
||||
|
||||
const {
|
||||
register,
|
||||
@ -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,9 +146,8 @@ 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")}
|
||||
placeholder="••••••••••••"
|
||||
@ -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">
|
||||
@ -213,8 +209,8 @@ const LoginPage = () => {
|
||||
{loading
|
||||
? "Please Wait..."
|
||||
: IsLoginWithOTP
|
||||
? "Send OTP"
|
||||
: "Sign In"}
|
||||
? "Send OTP"
|
||||
: "Sign In"}
|
||||
</button>
|
||||
|
||||
{/* Login With OTP Button */}
|
||||
@ -258,4 +254,4 @@ const LoginPage = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export default LoginPage;
|
||||
export default LoginPage;
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user