Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 49c639e8e2 |
@@ -14,7 +14,4 @@ VITE_APP_PREVIEW_DOCS_URL=https://www.wrenchboard.com/
|
|||||||
VITE_APP_THEME_API_URL=https://api.wrenchboard/api/api
|
VITE_APP_THEME_API_URL=https://api.wrenchboard/api/api
|
||||||
|
|
||||||
# main url
|
# main url
|
||||||
VITE_APP_MAINSITE_URL=https://www.wrenchboard.com
|
VITE_APP_MAINSITE_URL=https://www.wrenchboard.com
|
||||||
VITE_APP_SESSION_EXPIRE_CHECKER=60000
|
|
||||||
VITE_APP_SESSION_EXPIRE_MINUTES=900000
|
|
||||||
VITE_APP_WRENCH_IDENTITY_SITE=https://dev-ident.wrenchboard.com/
|
|
||||||
+1
-7
@@ -11,10 +11,4 @@ VITE_APP_PURCHASE_URL=https://themeforest.net/item/metronic-responsive-admin-das
|
|||||||
VITE_APP_PREVIEW_URL=https://preview.keenthemes.com/metronic8/react/demo1/
|
VITE_APP_PREVIEW_URL=https://preview.keenthemes.com/metronic8/react/demo1/
|
||||||
VITE_APP_PREVIEW_REACT_URL=https://preview.keenthemes.com/metronic8/react
|
VITE_APP_PREVIEW_REACT_URL=https://preview.keenthemes.com/metronic8/react
|
||||||
VITE_APP_PREVIEW_DOCS_URL=https://preview.keenthemes.com/metronic8/react/docs
|
VITE_APP_PREVIEW_DOCS_URL=https://preview.keenthemes.com/metronic8/react/docs
|
||||||
VITE_APP_THEME_API_URL=https://preview.keenthemes.com/theme-api/api
|
VITE_APP_THEME_API_URL=https://preview.keenthemes.com/theme-api/api
|
||||||
|
|
||||||
# main url
|
|
||||||
VITE_APP_MAINSITE_URL=https://www.wrenchboard.com
|
|
||||||
VITE_APP_SESSION_EXPIRE_CHECKER=60000
|
|
||||||
VITE_APP_SESSION_EXPIRE_MINUTES=900000
|
|
||||||
VITE_APP_WRENCH_IDENTITY_SITE=https://dev-ident.wrenchboard.com/
|
|
||||||
+1
-7
@@ -11,10 +11,4 @@ VITE_APP_PURCHASE_URL=https://themeforest.net/item/metronic-responsive-admin-das
|
|||||||
VITE_APP_PREVIEW_URL=https://preview.keenthemes.com/metronic8/react/demo1/
|
VITE_APP_PREVIEW_URL=https://preview.keenthemes.com/metronic8/react/demo1/
|
||||||
VITE_APP_PREVIEW_REACT_URL=https://preview.keenthemes.com/metronic8/react
|
VITE_APP_PREVIEW_REACT_URL=https://preview.keenthemes.com/metronic8/react
|
||||||
VITE_APP_PREVIEW_DOCS_URL=https://preview.keenthemes.com/metronic8/react/docs
|
VITE_APP_PREVIEW_DOCS_URL=https://preview.keenthemes.com/metronic8/react/docs
|
||||||
VITE_APP_THEME_API_URL=https://preview.keenthemes.com/theme-api/api
|
VITE_APP_THEME_API_URL=https://preview.keenthemes.com/theme-api/api
|
||||||
|
|
||||||
# main url
|
|
||||||
VITE_APP_MAINSITE_URL=https://www.wrenchboard.com
|
|
||||||
VITE_APP_SESSION_EXPIRE_CHECKER=60000
|
|
||||||
VITE_APP_SESSION_EXPIRE_MINUTES=900000
|
|
||||||
VITE_APP_WRENCH_IDENTITY_SITE=https://dev-ident.wrenchboard.com/
|
|
||||||
@@ -2,6 +2,10 @@ import { useEffect } from "react";
|
|||||||
import { Outlet, Link } from "react-router-dom";
|
import { Outlet, Link } from "react-router-dom";
|
||||||
import { toAbsoluteUrl } from "../../../_metronic/helpers";
|
import { toAbsoluteUrl } from "../../../_metronic/helpers";
|
||||||
|
|
||||||
|
interface EnvironmentVariables {
|
||||||
|
VITE_APP_MAINSITE_URL: string;
|
||||||
|
}
|
||||||
|
|
||||||
const AuthLayout = () => {
|
const AuthLayout = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const root = document.getElementById("root");
|
const root = document.getElementById("root");
|
||||||
@@ -80,7 +84,7 @@ const AuthLayout = () => {
|
|||||||
<img
|
<img
|
||||||
className="mx-auto w-275px w-md-50 w-xl-500px mb-10 mb-lg-20"
|
className="mx-auto w-275px w-md-50 w-xl-500px mb-10 mb-lg-20"
|
||||||
src={toAbsoluteUrl("media/misc/agents-auth-screens.png")}
|
src={toAbsoluteUrl("media/misc/agents-auth-screens.png")}
|
||||||
alt="WrenchBoard-start-img"
|
alt="wrenchboard-start-img"
|
||||||
/>
|
/>
|
||||||
{/* end::Image */}
|
{/* end::Image */}
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import { getUserByToken, login } from "../core/_requests";
|
|||||||
import { toAbsoluteUrl } from "../../../../_metronic/helpers";
|
import { toAbsoluteUrl } from "../../../../_metronic/helpers";
|
||||||
import { useAuth } from "../core/Auth";
|
import { useAuth } from "../core/Auth";
|
||||||
|
|
||||||
const SOCIAL_LINK = import.meta.env.VITE_APP_WRENCH_IDENTITY_SITE;
|
|
||||||
|
|
||||||
const loginSchema = Yup.object().shape({
|
const loginSchema = Yup.object().shape({
|
||||||
email: Yup.string()
|
email: Yup.string()
|
||||||
.email("Wrong email format")
|
.email("Wrong email format")
|
||||||
@@ -27,7 +25,7 @@ const initialValues = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// email: "admin@demo.com",
|
// email: "admin@demo.com",
|
||||||
// password: "demo",
|
// password: "demo",
|
||||||
/*
|
/*
|
||||||
Formik+YUP+Typescript:
|
Formik+YUP+Typescript:
|
||||||
https://jaredpalmer.com/formik/docs/tutorial#getfieldprops
|
https://jaredpalmer.com/formik/docs/tutorial#getfieldprops
|
||||||
@@ -77,9 +75,7 @@ export function Login() {
|
|||||||
<div className="col-md-6">
|
<div className="col-md-6">
|
||||||
{/* begin::Google link */}
|
{/* begin::Google link */}
|
||||||
<a
|
<a
|
||||||
href={SOCIAL_LINK}
|
href="#"
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
className="btn btn-flex btn-outline btn-text-gray-700 btn-active-color-primary bg-state-light flex-center text-nowrap w-100"
|
className="btn btn-flex btn-outline btn-text-gray-700 btn-active-color-primary bg-state-light flex-center text-nowrap w-100"
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
@@ -97,17 +93,20 @@ export function Login() {
|
|||||||
<div className="col-md-6">
|
<div className="col-md-6">
|
||||||
{/* begin::Google link */}
|
{/* begin::Google link */}
|
||||||
<a
|
<a
|
||||||
href={SOCIAL_LINK}
|
href="#"
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
className="btn btn-flex btn-outline btn-text-gray-700 btn-active-color-primary bg-state-light flex-center text-nowrap w-100"
|
className="btn btn-flex btn-outline btn-text-gray-700 btn-active-color-primary bg-state-light flex-center text-nowrap w-100"
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
alt="Logo"
|
alt="Logo"
|
||||||
src={toAbsoluteUrl("media/svg/brand-logos/facebook-4.svg")}
|
src={toAbsoluteUrl("media/svg/brand-logos/apple-black.svg")}
|
||||||
className="h-15px me-3"
|
className="theme-light-show h-15px me-3"
|
||||||
/>
|
/>
|
||||||
Sign in with Facebook
|
<img
|
||||||
|
alt="Logo"
|
||||||
|
src={toAbsoluteUrl("media/svg/brand-logos/apple-black-dark.svg")}
|
||||||
|
className="theme-dark-show h-15px me-3"
|
||||||
|
/>
|
||||||
|
Sign in with Apple
|
||||||
</a>
|
</a>
|
||||||
{/* end::Google link */}
|
{/* end::Google link */}
|
||||||
</div>
|
</div>
|
||||||
@@ -127,11 +126,13 @@ export function Login() {
|
|||||||
<div className="mb-lg-15 alert alert-danger">
|
<div className="mb-lg-15 alert alert-danger">
|
||||||
<div className="alert-text font-weight-bold">{formik.status}</div>
|
<div className="alert-text font-weight-bold">{formik.status}</div>
|
||||||
</div>
|
</div>
|
||||||
) : // <div className="mb-10 bg-light-info p-8 rounded">
|
) : (
|
||||||
|
// <div className="mb-10 bg-light-info p-8 rounded">
|
||||||
|
|
||||||
|
// </div>
|
||||||
|
|
||||||
// </div>
|
null
|
||||||
|
)}
|
||||||
null}
|
|
||||||
|
|
||||||
{/* begin::Form group */}
|
{/* begin::Form group */}
|
||||||
<div className="fv-row mb-8">
|
<div className="fv-row mb-8">
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import {
|
|||||||
FC,
|
FC,
|
||||||
useState,
|
useState,
|
||||||
useEffect,
|
useEffect,
|
||||||
useCallback,
|
|
||||||
createContext,
|
createContext,
|
||||||
useContext,
|
useContext,
|
||||||
Dispatch,
|
Dispatch,
|
||||||
@@ -40,15 +39,6 @@ const useAuth = () => {
|
|||||||
const AuthProvider: FC<WithChildren> = ({ children }) => {
|
const AuthProvider: FC<WithChildren> = ({ children }) => {
|
||||||
const [auth, setAuth] = useState<AuthModel | undefined>(authHelper.getAuth());
|
const [auth, setAuth] = useState<AuthModel | undefined>(authHelper.getAuth());
|
||||||
const [currentUser, setCurrentUser] = useState<UserModel | undefined>();
|
const [currentUser, setCurrentUser] = useState<UserModel | undefined>();
|
||||||
const [lastActivityTime, setLastActivityTime] = useState(Date.now());
|
|
||||||
|
|
||||||
let checkExpirationInMinutes: number = Number(
|
|
||||||
import.meta.env.VITE_APP_SESSION_EXPIRE_MINUTES
|
|
||||||
);
|
|
||||||
let expirationChecker: number = Number(
|
|
||||||
import.meta.env.VITE_APP_SESSION_EXPIRE_CHECKER
|
|
||||||
);
|
|
||||||
|
|
||||||
const saveAuth = (auth: AuthModel | undefined) => {
|
const saveAuth = (auth: AuthModel | undefined) => {
|
||||||
setAuth(auth);
|
setAuth(auth);
|
||||||
if (auth) {
|
if (auth) {
|
||||||
@@ -63,42 +53,6 @@ const AuthProvider: FC<WithChildren> = ({ children }) => {
|
|||||||
setCurrentUser(undefined);
|
setCurrentUser(undefined);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect((): any => {
|
|
||||||
const expireSession = () => {
|
|
||||||
localStorage.removeItem("wrenchboard-agent-auth-details");
|
|
||||||
logout();
|
|
||||||
};
|
|
||||||
|
|
||||||
const checkInactivity = setInterval(() => {
|
|
||||||
let currentTime: number = Date.now();
|
|
||||||
let checkLastActivityTime: number = lastActivityTime;
|
|
||||||
|
|
||||||
if (currentTime - checkLastActivityTime > checkExpirationInMinutes) {
|
|
||||||
expireSession();
|
|
||||||
}
|
|
||||||
}, expirationChecker);
|
|
||||||
|
|
||||||
// cleaning up listeners
|
|
||||||
return () => {
|
|
||||||
clearInterval(checkInactivity);
|
|
||||||
};
|
|
||||||
}, [lastActivityTime]);
|
|
||||||
|
|
||||||
// Reset last activity time on user input
|
|
||||||
const resetTime = useCallback(() => {
|
|
||||||
setLastActivityTime(Date.now());
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
window.addEventListener("mousemove", resetTime);
|
|
||||||
window.addEventListener("keydown", resetTime);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
window.removeEventListener("mousemove", resetTime);
|
|
||||||
window.removeEventListener("keydown", resetTime);
|
|
||||||
};
|
|
||||||
}, [resetTime]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthContext.Provider
|
<AuthContext.Provider
|
||||||
value={{ auth, saveAuth, currentUser, setCurrentUser, logout }}
|
value={{ auth, saveAuth, currentUser, setCurrentUser, logout }}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import {AuthModel} from './_models'
|
import {AuthModel} from './_models'
|
||||||
|
|
||||||
const AUTH_LOCAL_STORAGE_KEY = 'wrenchboard-agent-auth-details'
|
const AUTH_LOCAL_STORAGE_KEY = 'kt-auth-react-v'
|
||||||
const getAuth = (): AuthModel | undefined => {
|
const getAuth = (): AuthModel | undefined => {
|
||||||
if (!localStorage) {
|
if (!localStorage) {
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user