fixed refresh-token error and changed forgot password text position.
This commit is contained in:
parent
29caa20250
commit
d4452ae19a
@ -61,7 +61,7 @@ const LoginPage = () => {
|
|||||||
className="mb-3"
|
className="mb-3"
|
||||||
onSubmit={handleSubmit(onSubmit)}
|
onSubmit={handleSubmit(onSubmit)}
|
||||||
>
|
>
|
||||||
<div className="mb-0">
|
<div className="mb-2">
|
||||||
<label htmlFor="username" className="form-label">
|
<label htmlFor="username" className="form-label">
|
||||||
Email or Username
|
Email or Username
|
||||||
</label>
|
</label>
|
||||||
@ -84,16 +84,11 @@ const LoginPage = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-3 form-password-toggle">
|
<div className="mb-3 form-password-toggle">
|
||||||
<div className="d-flex justify-content-between">
|
<div className="d-flex justify-content-center">
|
||||||
<label className="form-label" htmlFor="password">
|
<label className="form-label" htmlFor="password">
|
||||||
Password
|
Password
|
||||||
</label>
|
</label>
|
||||||
<Link
|
|
||||||
aria-label="Go to Forgot Password Page"
|
|
||||||
to="/auth/forgot-password"
|
|
||||||
>
|
|
||||||
<small>Forgot Password?</small>
|
|
||||||
</Link>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="input-group input-group-merge">
|
<div className="input-group input-group-merge">
|
||||||
<input
|
<input
|
||||||
@ -126,8 +121,8 @@ const LoginPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-3">
|
<div className="mb-3 d-flex justify-content-between">
|
||||||
<div className="form-check">
|
<div className="form-check d-flex">
|
||||||
<input
|
<input
|
||||||
className="form-check-input"
|
className="form-check-input"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
@ -135,11 +130,17 @@ const LoginPage = () => {
|
|||||||
name="rememberMe"
|
name="rememberMe"
|
||||||
{...register("rememberMe")}
|
{...register("rememberMe")}
|
||||||
/>
|
/>
|
||||||
<label className="form-check-label" htmlFor="remember-me">
|
<label className="form-check-label ms-2" htmlFor="remember-me">
|
||||||
{" "}
|
{" "}
|
||||||
Remember Me{" "}
|
Remember Me{" "}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<Link
|
||||||
|
aria-label="Go to Forgot Password Page"
|
||||||
|
to="/auth/forgot-password"
|
||||||
|
>
|
||||||
|
<span>Forgot Password?</span>
|
||||||
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-3">
|
<div className="mb-3">
|
||||||
<button
|
<button
|
||||||
|
@ -11,7 +11,9 @@ import { hasUserPermission } from "../../utils/authUtils";
|
|||||||
import { MANAGE_EMPLOYEES } from "../../utils/constants";
|
import { MANAGE_EMPLOYEES } from "../../utils/constants";
|
||||||
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
||||||
|
|
||||||
const EmployeeList = () => {
|
const EmployeeList = () =>
|
||||||
|
{
|
||||||
|
|
||||||
const { profile: loginUser } = useProfile();
|
const { profile: loginUser } = useProfile();
|
||||||
const [selectedProject, setSelectedProject] = useState("");
|
const [selectedProject, setSelectedProject] = useState("");
|
||||||
const { projects, loading: projectLoading } = useProjects();
|
const { projects, loading: projectLoading } = useProjects();
|
||||||
|
@ -31,9 +31,11 @@ axiosClient.interceptors.request.use(
|
|||||||
// // Response interceptor to handle responses globally (optional)
|
// // Response interceptor to handle responses globally (optional)
|
||||||
// Add an interceptor to handle expired tokens
|
// Add an interceptor to handle expired tokens
|
||||||
axiosClient.interceptors.response.use(
|
axiosClient.interceptors.response.use(
|
||||||
|
|
||||||
|
|
||||||
(response) => response,
|
(response) => response,
|
||||||
async (error) => {
|
async (error) => {
|
||||||
// debugger;
|
debugger;
|
||||||
const originalRequest = error.config;
|
const originalRequest = error.config;
|
||||||
|
|
||||||
if (!originalRequest) {
|
if (!originalRequest) {
|
||||||
@ -48,28 +50,47 @@ axiosClient.interceptors.response.use(
|
|||||||
console.error(
|
console.error(
|
||||||
"Connection refused. Please ensure the server is running."
|
"Connection refused. Please ensure the server is running."
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ( error.config.url.indexOf( 'refresh-token' ) == -1 )
|
||||||
|
{
|
||||||
|
showToast("Server is unreachable. Try again later!", "error");
|
||||||
|
}
|
||||||
showToast(
|
showToast(
|
||||||
"Unable to connect to the server. Please try again later.",
|
"Unable to connect to the server. Please try again later.",
|
||||||
"error"
|
"error"
|
||||||
);
|
);
|
||||||
} else if (error.code === "ERR_NETWORK") {
|
} else if (error.code === "ERR_NETWORK") {
|
||||||
console.error("Network error: Unable to reach the server.");
|
console.error( "Network error: Unable to reach the server." );
|
||||||
showToast("Server is unreachable. Try again later!", "error");
|
if ( error.config.url.indexOf( 'refresh-token' ) == -1 )
|
||||||
|
{
|
||||||
|
showToast("Server is unreachable. Try again later!", "error");
|
||||||
|
}
|
||||||
redirectToLogin();
|
redirectToLogin();
|
||||||
} else if (error.code === "ECONNABORTED") {
|
} else if (error.code === "ECONNABORTED") {
|
||||||
console.error("Request timed out.");
|
console.error( "Request timed out." );
|
||||||
|
|
||||||
|
if ( error.config.url.indexOf( 'refresh-token' ) == -1 )
|
||||||
|
{
|
||||||
|
showToast("Server is unreachable. Try again later!", "error");
|
||||||
|
}
|
||||||
showToast(
|
showToast(
|
||||||
"The request took too long. Please try again later.",
|
"The request took too long. Please try again later.",
|
||||||
"error"
|
"error"
|
||||||
);
|
);
|
||||||
} else if (error.response) {
|
} else if ( error.response )
|
||||||
|
{
|
||||||
|
|
||||||
|
if ( error.config.url.indexOf( 'refresh-token' ) == -1 )
|
||||||
|
{
|
||||||
|
showToast("Server is unreachable. Try again later!", "error");
|
||||||
|
}
|
||||||
showToast(error.response.data.message, "error");
|
showToast(error.response.data.message, "error");
|
||||||
|
|
||||||
if (error.response.status === 401 && !originalRequest._retry) {
|
if (error.response.status === 401 && !originalRequest._retry) {
|
||||||
originalRequest._retry = true;
|
originalRequest._retry = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// debugger;
|
|
||||||
// Get the refresh token from secure storage
|
// Get the refresh token from secure storage
|
||||||
const refreshToken = localStorage.getItem("refreshToken");
|
const refreshToken = localStorage.getItem("refreshToken");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user