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 { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { AuthWrapper } from "./AuthWrapper";
|
import { AuthWrapper } from "./AuthWrapper";
|
||||||
import { setOrgToken } from "../../services/tenantService";
|
|
||||||
const LoginPage = () => {
|
const LoginPage = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
@ -16,13 +16,13 @@ const LoginPage = () => {
|
|||||||
|
|
||||||
const loginSchema = IsLoginWithOTP
|
const loginSchema = IsLoginWithOTP
|
||||||
? z.object({
|
? z.object({
|
||||||
username: z.string().trim().email({ message: "Valid email required" }),
|
username: z.string().trim().email({ message: "Valid email required" }),
|
||||||
})
|
})
|
||||||
: z.object({
|
: z.object({
|
||||||
username: z.string().trim().email({ message: "Valid email required" }),
|
username: z.string().trim().email({ message: "Valid email required" }),
|
||||||
password: z.string().trim().min(1, { message: "Password required" }),
|
password: z.string().trim().min(1, { message: "Password required" }),
|
||||||
rememberMe: z.boolean(),
|
rememberMe: z.boolean(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
@ -41,11 +41,10 @@ const LoginPage = () => {
|
|||||||
password: data.password,
|
password: data.password,
|
||||||
};
|
};
|
||||||
const response = await AuthRepository.login(userCredential);
|
const response = await AuthRepository.login(userCredential);
|
||||||
// localStorage.setItem("jwtToken", response.data.token);
|
localStorage.setItem("jwtToken", response.data.token);
|
||||||
// localStorage.setItem("refreshToken", response.data.refreshToken);
|
localStorage.setItem("refreshToken", response.data.refreshToken);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
setOrgToken(response.data.token, response.data.refreshToken);
|
navigate("/dashboard");
|
||||||
navigate("/auth/user");
|
|
||||||
} else {
|
} else {
|
||||||
await AuthRepository.sendOTP({ email: data.username });
|
await AuthRepository.sendOTP({ email: data.username });
|
||||||
showToast("OTP has been sent to your email.", "success");
|
showToast("OTP has been sent to your email.", "success");
|
||||||
@ -147,9 +146,8 @@ const LoginPage = () => {
|
|||||||
type={hidepass ? "password" : "text"}
|
type={hidepass ? "password" : "text"}
|
||||||
autoComplete="new-password"
|
autoComplete="new-password"
|
||||||
id="password"
|
id="password"
|
||||||
className={`form-control form-control-xl shadow-none ${
|
className={`form-control form-control-xl shadow-none ${errors.password ? "is-invalid" : ""
|
||||||
errors.password ? "is-invalid" : ""
|
}`}
|
||||||
}`}
|
|
||||||
name="password"
|
name="password"
|
||||||
{...register("password")}
|
{...register("password")}
|
||||||
placeholder="••••••••••••"
|
placeholder="••••••••••••"
|
||||||
@ -172,15 +170,13 @@ const LoginPage = () => {
|
|||||||
|
|
||||||
{/* ✅ Error message */}
|
{/* ✅ Error message */}
|
||||||
{errors.password && (
|
{errors.password && (
|
||||||
<div
|
<div className="invalid-feedback text-start" style={{ fontSize: "12px" }}>
|
||||||
className="invalid-feedback text-start"
|
|
||||||
style={{ fontSize: "12px" }}
|
|
||||||
>
|
|
||||||
{errors.password.message}
|
{errors.password.message}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{/* Remember Me + Forgot Password */}
|
{/* Remember Me + Forgot Password */}
|
||||||
<div className="mb-3 d-flex justify-content-between align-items-center">
|
<div className="mb-3 d-flex justify-content-between align-items-center">
|
||||||
<div className="form-check">
|
<div className="form-check">
|
||||||
@ -213,8 +209,8 @@ const LoginPage = () => {
|
|||||||
{loading
|
{loading
|
||||||
? "Please Wait..."
|
? "Please Wait..."
|
||||||
: IsLoginWithOTP
|
: IsLoginWithOTP
|
||||||
? "Send OTP"
|
? "Send OTP"
|
||||||
: "Sign In"}
|
: "Sign In"}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{/* Login With OTP Button */}
|
{/* Login With OTP Button */}
|
||||||
|
@ -15,23 +15,8 @@ const AuthRepository = {
|
|||||||
logout: (data) => api.post("/api/auth/logout", data),
|
logout: (data) => api.post("/api/auth/logout", data),
|
||||||
profile: () => api.get("/api/user/profile"),
|
profile: () => api.get("/api/user/profile"),
|
||||||
changepassword: (data) => api.post("/api/auth/change-password", data),
|
changepassword: (data) => api.post("/api/auth/change-password", data),
|
||||||
appmenu: () => api.get("/api/appmenu/get/menu"),
|
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}`),
|
|
||||||
|
|
||||||
// ---------------- 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;
|
export default AuthRepository;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user