@acuteinfo/common-screens 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.hintrc +14 -0
- package/README.md +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1472 -0
- package/dist/index.js.map +1 -0
- package/dist/pages/auth/api.d.ts +1 -0
- package/dist/pages/auth/authController.d.ts +17 -0
- package/dist/pages/auth/bankDetails.d.ts +1 -0
- package/dist/pages/auth/biometric.d.ts +1 -0
- package/dist/pages/auth/otpPopup.d.ts +26 -0
- package/dist/pages/auth/passwordRotation.d.ts +9 -0
- package/dist/pages/auth/style.d.ts +1 -0
- package/dist/pages/auth/usernamePassword.d.ts +5 -0
- package/dist/pages/auth/verifyFinger.d.ts +7 -0
- package/package.json +106 -0
- package/resources.txt +52 -0
- package/rollup.config.mjs +50 -0
- package/tsconfig.json +25 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1472 @@
|
|
|
1
|
+
import 'regenerator-runtime/runtime';
|
|
2
|
+
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
3
|
+
import { TextField, GradientButton, utilFunction, FullScreenLoader } from '@acuteinfo/common-base';
|
|
4
|
+
import { useState, useRef, useEffect, Fragment, useMemo, useReducer } from 'react';
|
|
5
|
+
import { useNavigate } from 'react-router-dom';
|
|
6
|
+
import { makeStyles } from '@mui/styles';
|
|
7
|
+
import Visibility from '@mui/icons-material/Visibility';
|
|
8
|
+
import VisibilityOff from '@mui/icons-material/VisibilityOff';
|
|
9
|
+
import { Container, Grid, InputAdornment, IconButton, CircularProgress, FormHelperText, Typography, Tooltip } from '@mui/material';
|
|
10
|
+
import { useTranslation } from 'react-i18next';
|
|
11
|
+
import OTPInput, { ResendOTP } from 'otp-input-react';
|
|
12
|
+
import IconButton$1 from '@mui/material/IconButton';
|
|
13
|
+
import clsx from 'clsx';
|
|
14
|
+
import { useSnackbar } from 'notistack';
|
|
15
|
+
import FingerprintSharpIcon from '@mui/icons-material/FingerprintSharp';
|
|
16
|
+
import CryptoJS from 'crypto-js';
|
|
17
|
+
|
|
18
|
+
const useStyles = makeStyles((theme) => ({
|
|
19
|
+
wrapper: {
|
|
20
|
+
minHeight: "100vh",
|
|
21
|
+
boxShadow: "0 3px 6px rgba(0,0,0,0.03)",
|
|
22
|
+
// background: "#fff",
|
|
23
|
+
background: "var(--theme-color2)",
|
|
24
|
+
},
|
|
25
|
+
loginEmp: {
|
|
26
|
+
background: "#fff",
|
|
27
|
+
padding: theme.spacing(2, 4),
|
|
28
|
+
display: "flex",
|
|
29
|
+
maxWidth: "400px",
|
|
30
|
+
margin: "auto",
|
|
31
|
+
boxShadow: "0 0 20px rgba(0,0,0,0.06)",
|
|
32
|
+
borderRadius: "8px",
|
|
33
|
+
[theme.breakpoints.down("sm")]: {
|
|
34
|
+
width: "100%",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
formWrap: {
|
|
38
|
+
marginTop: theme.spacing(2),
|
|
39
|
+
},
|
|
40
|
+
loginBtn: {
|
|
41
|
+
minWidth: "100% !important",
|
|
42
|
+
margin: theme.spacing(2, 0),
|
|
43
|
+
fontSize: "1rem",
|
|
44
|
+
padding: "10px .75rem",
|
|
45
|
+
background: "rgb(128,0,0)",
|
|
46
|
+
border: 0,
|
|
47
|
+
color: "#fff !important",
|
|
48
|
+
fontWeight: 600,
|
|
49
|
+
letterSpacing: "0.02857em",
|
|
50
|
+
boxShadow: "none",
|
|
51
|
+
textTransform: "capitalize",
|
|
52
|
+
alignSelf: "flex-end",
|
|
53
|
+
"&:hover": {
|
|
54
|
+
background: "#fedad8",
|
|
55
|
+
boxShadow: "none",
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
OTPTimer: {
|
|
59
|
+
marginTop: "10px",
|
|
60
|
+
color: theme.palette.primary.main,
|
|
61
|
+
fontWeight: 600,
|
|
62
|
+
},
|
|
63
|
+
resendLink: {
|
|
64
|
+
marginTop: "10px",
|
|
65
|
+
cursor: "pointer",
|
|
66
|
+
color: theme.palette.secondary.main,
|
|
67
|
+
fontWeight: 600,
|
|
68
|
+
fontSize: "0.875 rem",
|
|
69
|
+
},
|
|
70
|
+
logo: {
|
|
71
|
+
marginBottom: theme.spacing(1),
|
|
72
|
+
},
|
|
73
|
+
loginLeft: {
|
|
74
|
+
[theme.breakpoints.down("sm")]: {
|
|
75
|
+
display: "none",
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
loginRight: {
|
|
79
|
+
background: "#fff",
|
|
80
|
+
padding: theme.spacing(2, 4),
|
|
81
|
+
display: "flex",
|
|
82
|
+
maxWidth: "400px",
|
|
83
|
+
margin: "auto",
|
|
84
|
+
boxShadow: "0 0 20px rgba(0,0,0,0.06)",
|
|
85
|
+
borderRadius: "8px",
|
|
86
|
+
[theme.breakpoints.down("sm")]: {
|
|
87
|
+
width: "100%",
|
|
88
|
+
},
|
|
89
|
+
"& img": {
|
|
90
|
+
alignSelf: "center",
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
loginImg: {},
|
|
94
|
+
verifybutton: {
|
|
95
|
+
alignSelf: "center",
|
|
96
|
+
// marginBottom: "10px",
|
|
97
|
+
// marginTop: "10px",
|
|
98
|
+
padding: "5px",
|
|
99
|
+
},
|
|
100
|
+
otpButtons: {
|
|
101
|
+
// padding: "10px",
|
|
102
|
+
},
|
|
103
|
+
divflex: {
|
|
104
|
+
display: "flex",
|
|
105
|
+
},
|
|
106
|
+
otpinputpadding: {
|
|
107
|
+
"& input": {
|
|
108
|
+
marginRight: "25px !important",
|
|
109
|
+
border: "1.42444px solid var(--theme-color3)",
|
|
110
|
+
borderRadius: "10px",
|
|
111
|
+
width: "45px !important",
|
|
112
|
+
height: "45px !important",
|
|
113
|
+
marginBottom: "15px",
|
|
114
|
+
boxShadow: "0px 5.69775px 11.3955px rgba(66, 99, 199, 0.16)",
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
ibtnvisible: {
|
|
118
|
+
// padding: "7px !important",
|
|
119
|
+
// alignItems: "baseline",
|
|
120
|
+
marginBottom: "15px",
|
|
121
|
+
},
|
|
122
|
+
btnvisibleoff: {
|
|
123
|
+
display: "none",
|
|
124
|
+
},
|
|
125
|
+
OTPalignName: {
|
|
126
|
+
display: "flex",
|
|
127
|
+
alignItems: "center",
|
|
128
|
+
// justifyContent: "space-between",
|
|
129
|
+
marginBottom: "12px",
|
|
130
|
+
color: "#1C1C1C",
|
|
131
|
+
fonWeight: "400",
|
|
132
|
+
fontSize: "17px",
|
|
133
|
+
lineHeight: "33px",
|
|
134
|
+
},
|
|
135
|
+
resendOTPalign: {
|
|
136
|
+
color: "var(--theme-color3)",
|
|
137
|
+
fonWeight: "400",
|
|
138
|
+
fontSize: "17px",
|
|
139
|
+
lineHeight: "33px",
|
|
140
|
+
margin: "0 auto",
|
|
141
|
+
// marginTop: "15px",
|
|
142
|
+
// display: "block !important",
|
|
143
|
+
},
|
|
144
|
+
resendbtnLink: {
|
|
145
|
+
textDecoration: "underline",
|
|
146
|
+
color: "var(--theme-color3)",
|
|
147
|
+
cursor: "pointer",
|
|
148
|
+
"&:hover": {
|
|
149
|
+
textDecoration: "underline",
|
|
150
|
+
color: "var(--theme-color3)",
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
dialogTitleClass: {
|
|
154
|
+
background: "var(--theme-color5)",
|
|
155
|
+
padding: "6px 15px !important",
|
|
156
|
+
margin: "10px",
|
|
157
|
+
color: "var(--theme-color2)",
|
|
158
|
+
borderRadius: "4px",
|
|
159
|
+
"& h2": {
|
|
160
|
+
fontWeight: "500 !important",
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
lang_svg: {
|
|
164
|
+
marginRight: "10px",
|
|
165
|
+
width: "22px",
|
|
166
|
+
height: "22px",
|
|
167
|
+
},
|
|
168
|
+
dialogContent: {
|
|
169
|
+
padding: "0px 15px",
|
|
170
|
+
"& p": {
|
|
171
|
+
whiteSpace: "pre-wrap",
|
|
172
|
+
color: "black",
|
|
173
|
+
marginTop: "8px",
|
|
174
|
+
marginBottom: "6px",
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
button: {
|
|
178
|
+
display: "flex",
|
|
179
|
+
alignItems: "center",
|
|
180
|
+
justifyContent: "center",
|
|
181
|
+
flexDirection: "column",
|
|
182
|
+
margin: "6px",
|
|
183
|
+
background: "var(--theme-color1)",
|
|
184
|
+
"&:hover": {
|
|
185
|
+
background: "var(--theme-color1) !important",
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
}));
|
|
189
|
+
|
|
190
|
+
// import { Language_App } from "pages_audit/appBar/language";
|
|
191
|
+
const UsernamePasswordField = ({ classes, loginState, verifyUsernamePassword, }) => {
|
|
192
|
+
const [input, setInput] = useState({ userName: "", password: "" });
|
|
193
|
+
const [showPasswordTime, setShowPasswordTime] = useState(0);
|
|
194
|
+
const showPassword = Date.now() < showPasswordTime;
|
|
195
|
+
const [, forceUpdate] = useState();
|
|
196
|
+
const timerRef = useRef(null);
|
|
197
|
+
const { t } = useTranslation();
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
return () => clearTimeout(timerRef.current);
|
|
200
|
+
}, []);
|
|
201
|
+
const handleChange = (event) => {
|
|
202
|
+
const name = event.target.name;
|
|
203
|
+
const value = event.target.value;
|
|
204
|
+
if (name === "userName" && value) {
|
|
205
|
+
loginState.isUsernameError = false;
|
|
206
|
+
}
|
|
207
|
+
if (name === "password" && value) {
|
|
208
|
+
loginState.isPasswordError = false;
|
|
209
|
+
}
|
|
210
|
+
setInput((values) => ({ ...values, [name]: value }));
|
|
211
|
+
};
|
|
212
|
+
const inputRef = useRef(null);
|
|
213
|
+
const inputPassRef = useRef(null);
|
|
214
|
+
const inputButtonRef = useRef(null);
|
|
215
|
+
useEffect(() => {
|
|
216
|
+
let timeoutCd;
|
|
217
|
+
if (loginState.isUsernameError) {
|
|
218
|
+
timeoutCd = setTimeout(() => {
|
|
219
|
+
inputRef?.current?.focus?.();
|
|
220
|
+
}, 1000);
|
|
221
|
+
}
|
|
222
|
+
else if (loginState.isPasswordError) {
|
|
223
|
+
timeoutCd = setTimeout(() => {
|
|
224
|
+
inputPassRef?.current?.focus?.();
|
|
225
|
+
}, 1000);
|
|
226
|
+
}
|
|
227
|
+
return () => {
|
|
228
|
+
if (timeoutCd) {
|
|
229
|
+
clearTimeout(timeoutCd);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
}, [loginState.isUsernameError, loginState.isPasswordError]);
|
|
233
|
+
useEffect(() => {
|
|
234
|
+
let timeoutCd;
|
|
235
|
+
if (loginState?.otpmodelClose ?? false) {
|
|
236
|
+
setInput((values) => ({ ...values, password: "" }));
|
|
237
|
+
timeoutCd = setTimeout(() => {
|
|
238
|
+
inputPassRef?.current?.focus?.();
|
|
239
|
+
}, 1500);
|
|
240
|
+
}
|
|
241
|
+
return () => {
|
|
242
|
+
if (timeoutCd) {
|
|
243
|
+
clearTimeout(timeoutCd);
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
}, [loginState.otpmodelClose]);
|
|
247
|
+
return (jsx(Fragment, { children: jsx(Container, { maxWidth: "xs", children: jsxs(Grid, { alignItems: "center", style: { paddingTop: "20px" }, children: [jsx("div", { style: {
|
|
248
|
+
color: "#000000 !important",
|
|
249
|
+
fontSize: "30px",
|
|
250
|
+
fontWeight: "600",
|
|
251
|
+
// fontFamily: "Poppins",
|
|
252
|
+
alignItems: "center",
|
|
253
|
+
fontStyle: "normal",
|
|
254
|
+
lineHeight: "150%",
|
|
255
|
+
}, children: jsx("h3", { children: t("SignIn") }) }), jsx("div", { className: "", style: {
|
|
256
|
+
color: "#949597",
|
|
257
|
+
fontSize: "16px",
|
|
258
|
+
fontWeight: "400",
|
|
259
|
+
// fontFamily: "Poppins",
|
|
260
|
+
alignItems: "center",
|
|
261
|
+
fontStyle: "normal",
|
|
262
|
+
width: "360px",
|
|
263
|
+
}, children: t("SignInWithUserIDandPassword") }), jsxs("div", { className: classes.formWrap, children: [jsx(TextField
|
|
264
|
+
// variant="filled"
|
|
265
|
+
// color="secondary"
|
|
266
|
+
, {
|
|
267
|
+
// variant="filled"
|
|
268
|
+
// color="secondary"
|
|
269
|
+
autoFocus: true, label: t("UserID"),
|
|
270
|
+
// placeholder="User ID"
|
|
271
|
+
placeholder: String(t("UserID")), style: {
|
|
272
|
+
marginTop: "10px",
|
|
273
|
+
marginBottom: "17px",
|
|
274
|
+
}, fullWidth: true, type: "text", name: "userName", value: input.userName.trimStart() || "", onChange: handleChange, error: loginState.isUsernameError, helperText: loginState.isUsernameError
|
|
275
|
+
? t(loginState.userMessageforusername)
|
|
276
|
+
: "", InputLabelProps: { shrink: true }, disabled: loginState.loading, autoComplete: "off", ref: inputRef, onKeyDown: (e) => {
|
|
277
|
+
if (e.key === "Enter") {
|
|
278
|
+
inputButtonRef?.current?.click?.();
|
|
279
|
+
}
|
|
280
|
+
}, inputProps: {
|
|
281
|
+
maxLength: "16",
|
|
282
|
+
} }), jsx("div", { style: {
|
|
283
|
+
display: "flex",
|
|
284
|
+
flexDirection: "row-reverse",
|
|
285
|
+
marginTop: "8px",
|
|
286
|
+
}, children: jsx(TextField, { label: t("Password"),
|
|
287
|
+
// variant="filled"
|
|
288
|
+
// color="secondary"
|
|
289
|
+
placeholder: String(t("EnterPassword")), InputLabelProps: {
|
|
290
|
+
shrink: true,
|
|
291
|
+
}, fullWidth: true, type: showPassword ? "text" : "password", name: "password", value: input.password, onChange: handleChange, error: loginState.isPasswordError, helperText: loginState.isPasswordError
|
|
292
|
+
? t(loginState.userMessageforpassword)
|
|
293
|
+
: "", disabled: loginState.loading, ref: inputPassRef, onKeyDown: (e) => {
|
|
294
|
+
if (e.key === "Enter") {
|
|
295
|
+
inputButtonRef?.current?.click?.();
|
|
296
|
+
}
|
|
297
|
+
}, InputProps: {
|
|
298
|
+
endAdornment: (jsx(InputAdornment, { position: "end", children: jsx(IconButton, { "aria-label": "toggle password visibility", onClick: () => {
|
|
299
|
+
if (!showPassword) {
|
|
300
|
+
setShowPasswordTime(Date.now() + 5000);
|
|
301
|
+
timerRef.current = setTimeout(() => forceUpdate(Date.now()), 5000);
|
|
302
|
+
}
|
|
303
|
+
else if (showPassword)
|
|
304
|
+
setShowPasswordTime(0);
|
|
305
|
+
}, onMouseDown: (e) => e.preventDefault(), disabled: loginState.loading, children: showPassword ? jsx(Visibility, {}) : jsx(VisibilityOff, {}) }) })),
|
|
306
|
+
}, inputProps: { maxLength: "16" } }, "employee") }), jsx("div", { style: { marginTop: "20px", display: "flex" }, children: jsx("div", { style: { flex: "auto", textAlign: "end" }, children: jsx("a", { href: "forgotpassword", style: { color: "var(--theme-color3)" }, children: t("ForgotPassword") }) }) }), jsx("div", { style: { marginTop: "20px", display: "flex" }, children: jsx("div", { style: {
|
|
307
|
+
flex: "auto",
|
|
308
|
+
textAlign: "center",
|
|
309
|
+
marginTop: "5px",
|
|
310
|
+
marginBottom: "17px",
|
|
311
|
+
}, children: jsx(GradientButton, { style: {
|
|
312
|
+
borderRadius: loginState.loading ? "50%" : "10px",
|
|
313
|
+
height: loginState.loading ? "40px" : "100%",
|
|
314
|
+
width: loginState.loading ? "0px" : "100%",
|
|
315
|
+
minWidth: loginState.loading ? "40px" : "80px",
|
|
316
|
+
}, fullWidth: true, disabled: loginState.loading, onClick: () => verifyUsernamePassword((input.userName || "").toLowerCase(), input.password), ref: inputButtonRef, children: loginState.loading ? (jsx(CircularProgress, { size: 25, thickness: 4.6 })) : (t("Next")) }) }) })] })] }) }) }));
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
const OTPModel = ({ classes, OTPResendRequest, open, handleClose, loginState, VerifyOTP, OTPError, setOTPError, previousStep, setNewRequestID = (id) => { }, otpresendCount = 0, resendFlag, }) => {
|
|
320
|
+
const [OTP, setOTP] = useState("");
|
|
321
|
+
const [showPasswordTime, setShowPasswordTime] = useState(0);
|
|
322
|
+
const showPassword = Date.now() < showPasswordTime;
|
|
323
|
+
const [, forceUpdate] = useState();
|
|
324
|
+
const timerRef = useRef(null);
|
|
325
|
+
useEffect(() => {
|
|
326
|
+
return () => clearTimeout(timerRef.current);
|
|
327
|
+
}, []);
|
|
328
|
+
const [btnshow, setbtnshow] = useState(false);
|
|
329
|
+
const inputButtonRef = useRef(null);
|
|
330
|
+
const [resendotpLoading, setResendotpLoading] = useState(false);
|
|
331
|
+
const { enqueueSnackbar } = useSnackbar();
|
|
332
|
+
const { t } = useTranslation();
|
|
333
|
+
// const renderButton = (buttonProps) => {
|
|
334
|
+
// let { remainingTime, ...other } = buttonProps;
|
|
335
|
+
// return resendotpLoading ? (
|
|
336
|
+
// <a
|
|
337
|
+
// remainingtime={remainingTime}
|
|
338
|
+
// {...other}
|
|
339
|
+
// className={clsx(
|
|
340
|
+
// classes.resendbtnLink,
|
|
341
|
+
// !btnshow && classes.btnvisibleoff
|
|
342
|
+
// )}
|
|
343
|
+
// >
|
|
344
|
+
// {t("otp.ResendOTP")}
|
|
345
|
+
// </a>
|
|
346
|
+
// ) : null;
|
|
347
|
+
// };
|
|
348
|
+
const renderButton = (buttonProps) => {
|
|
349
|
+
let { remainingTime, ...other } = buttonProps;
|
|
350
|
+
return resendotpLoading ? (jsxs("a", { className: clsx(classes.resendbtnLink, !btnshow && classes.btnvisibleoff), style: { cursor: "wait" }, children: [t("otp.GetNewOTP"), " ", jsx(CircularProgress, { size: 20, color: "secondary" })] })) : (jsx("a", { remainingtime: remainingTime, ...other, className: clsx(classes.resendbtnLink, !btnshow && classes.btnvisibleoff), children: t("otp.GetNewOTP") }));
|
|
351
|
+
};
|
|
352
|
+
const ClickEventHandler = () => {
|
|
353
|
+
if (!Boolean(OTP) || OTP.length < 6) {
|
|
354
|
+
setOTPError("otp.EnterOTPDigit");
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
setOTPError("");
|
|
358
|
+
VerifyOTP(OTP);
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
const handleResendClick = async () => {
|
|
362
|
+
setResendotpLoading(true);
|
|
363
|
+
const { status, data, message } = await OTPResendRequest(resendFlag === "FORGET_PW" || resendFlag === "FORGT_TOTP"
|
|
364
|
+
? loginState?.requestCd
|
|
365
|
+
: loginState?.transactionID, loginState?.username, resendFlag, loginState.auth_data?.[0]?.company_ID, loginState.auth_data?.[0]?.branch_cd);
|
|
366
|
+
setResendotpLoading(false);
|
|
367
|
+
if (status === "0") {
|
|
368
|
+
setNewRequestID(data?.TRAN_CD);
|
|
369
|
+
setbtnshow(false);
|
|
370
|
+
enqueueSnackbar(message, { variant: "success" });
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
enqueueSnackbar(message, { variant: "error" });
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
const handleCloseEvent = () => {
|
|
377
|
+
setOTPError("");
|
|
378
|
+
setOTP("");
|
|
379
|
+
handleClose("");
|
|
380
|
+
};
|
|
381
|
+
const renderTime = (remainingtime) => {
|
|
382
|
+
if (parseInt(remainingtime) === 0) {
|
|
383
|
+
setTimeout(() => {
|
|
384
|
+
setbtnshow(true);
|
|
385
|
+
}, 700);
|
|
386
|
+
}
|
|
387
|
+
return (jsxs("span", { className: clsx(btnshow && classes.btnvisibleoff), children: [t("otp.OtpExpired"), " ", remainingtime, " ", t("otp.second")] }));
|
|
388
|
+
};
|
|
389
|
+
useEffect(() => {
|
|
390
|
+
if (loginState?.otpmodelClose ?? false) {
|
|
391
|
+
handleCloseEvent();
|
|
392
|
+
}
|
|
393
|
+
}, [loginState.otpmodelClose]);
|
|
394
|
+
return (jsx(Fragment, { children: jsx(Container, { maxWidth: "sm", children: jsx(Grid, { alignItems: "center", marginTop: "4em", children: jsxs("div", {
|
|
395
|
+
// className={classes.formWrap}
|
|
396
|
+
style: {
|
|
397
|
+
// marginRight: "25px",
|
|
398
|
+
// width: "100%",
|
|
399
|
+
// position: "relative",
|
|
400
|
+
// right: "42px",
|
|
401
|
+
// bottom: "13px",
|
|
402
|
+
}, children: [jsx("div", { style: {
|
|
403
|
+
color: "#000000",
|
|
404
|
+
fontSize: "30px",
|
|
405
|
+
fontWeight: "600",
|
|
406
|
+
// fontFamily: "Poppins",
|
|
407
|
+
alignItems: "center",
|
|
408
|
+
fontStyle: "normal",
|
|
409
|
+
lineHeight: "150%",
|
|
410
|
+
marginBottom: "10px",
|
|
411
|
+
}, children: t("otp.OTPAuthentication") }), jsx("div", { style: {
|
|
412
|
+
color: "#949597",
|
|
413
|
+
fontSize: "16px",
|
|
414
|
+
fontWeight: "400",
|
|
415
|
+
alignItems: "center",
|
|
416
|
+
fontStyle: "normal",
|
|
417
|
+
lineHeight: "33px",
|
|
418
|
+
}, children: t("otp.EnterOTP") }), jsxs("div", { className: classes.OTPalignName, children: [t("otp.Hello"), " ", loginState?.username
|
|
419
|
+
? loginState.username.charAt(0).toUpperCase() +
|
|
420
|
+
loginState.username.slice(1)
|
|
421
|
+
: null, jsx(ResendOTP
|
|
422
|
+
// onResendClick={() => setbtnshow(false)}
|
|
423
|
+
, {
|
|
424
|
+
// onResendClick={() => setbtnshow(false)}
|
|
425
|
+
onResendClick: handleResendClick,
|
|
426
|
+
// onTimerComplete={() => setbtnshow(true)}
|
|
427
|
+
renderButton: renderButton, renderTime: renderTime, maxTime: loginState?.otpValidFor ?? 60, className: classes.resendOTPalign })] }), jsxs("div", { className: classes.divflex, onKeyDown: (e) => {
|
|
428
|
+
if (e.key === "Enter") {
|
|
429
|
+
inputButtonRef?.current?.click?.();
|
|
430
|
+
}
|
|
431
|
+
}, children: [jsx(OTPInput, { value: OTP, onChange: setOTP, autoFocus: true, OTPLength: 6, otpType: "number", disabled: false, secure: !showPassword, className: classes.otpinputpadding }), jsx(IconButton$1, { "aria-label": "toggle password visibility", onClick: () => {
|
|
432
|
+
if (!showPassword) {
|
|
433
|
+
setShowPasswordTime(Date.now() + 5000);
|
|
434
|
+
timerRef.current = setTimeout(() => forceUpdate(Date.now()), 5000);
|
|
435
|
+
}
|
|
436
|
+
else if (showPassword)
|
|
437
|
+
setShowPasswordTime(0);
|
|
438
|
+
}, onMouseDown: (e) => e.preventDefault(), disabled: loginState.otploading, className: classes.ibtnvisible, children: showPassword ? jsx(Visibility, {}) : jsx(VisibilityOff, {}) })] }), Boolean(OTPError) ? (jsx(FormHelperText, { style: { color: "red" }, children: OTPError })) : null, jsxs("div", { style: {
|
|
439
|
+
display: "flex",
|
|
440
|
+
gap: "10px",
|
|
441
|
+
margin: "42px 0 0 42px",
|
|
442
|
+
width: "60%",
|
|
443
|
+
}, children: [jsx(GradientButton
|
|
444
|
+
// fullWidth
|
|
445
|
+
, {
|
|
446
|
+
// fullWidth
|
|
447
|
+
disabled: loginState.otploading, onClick: () => {
|
|
448
|
+
previousStep(false, "");
|
|
449
|
+
}, className: classes.otpButtons,
|
|
450
|
+
// color={"var(--theme-color3) "}
|
|
451
|
+
sx: {
|
|
452
|
+
border: "var(--theme-color3)1px solid",
|
|
453
|
+
minWidth: "50%",
|
|
454
|
+
background: "var(--theme-color2)",
|
|
455
|
+
borderRadius: "10px",
|
|
456
|
+
"&:hover": {
|
|
457
|
+
background: "var(--theme-color2) !important",
|
|
458
|
+
},
|
|
459
|
+
}, children: t("otp.Back") }), jsx(GradientButton, { style: {
|
|
460
|
+
borderRadius: loginState.loading ? "50%" : "10px",
|
|
461
|
+
height: loginState.loading ? "40px" : "100%",
|
|
462
|
+
width: loginState.loading ? "0px" : "100%",
|
|
463
|
+
minWidth: loginState.loading ? "40px" : "80px",
|
|
464
|
+
}, fullWidth: true, disabled: loginState.loading, onClick: ClickEventHandler, ref: inputButtonRef, className: classes.otpButtons, children: loginState.loading ? (jsx(CircularProgress, { size: 25, thickness: 4.6 })) : (t("otp.VerifyOTP")) })] })] }) }) }) }));
|
|
465
|
+
};
|
|
466
|
+
const OTPModelForm = ({ classes, OTPResendRequest, handleClose, loginState, VerifyOTP, OTPError, setOTPError, resendFlag, setNewRequestID = (id) => { }, otpresendCount = 0, }) => {
|
|
467
|
+
const [OTP, setOTP] = useState("");
|
|
468
|
+
const [showPasswordTime, setShowPasswordTime] = useState(0);
|
|
469
|
+
const showPassword = Date.now() < showPasswordTime;
|
|
470
|
+
const [, forceUpdate] = useState();
|
|
471
|
+
const timerRef = useRef(null);
|
|
472
|
+
useEffect(() => {
|
|
473
|
+
return () => clearTimeout(timerRef.current);
|
|
474
|
+
}, []);
|
|
475
|
+
const [btnshow, setbtnshow] = useState(false);
|
|
476
|
+
const [resendotpLoading, setResendotpLoading] = useState(false);
|
|
477
|
+
const inputButtonRef = useRef(null);
|
|
478
|
+
const { enqueueSnackbar } = useSnackbar();
|
|
479
|
+
const { t } = useTranslation();
|
|
480
|
+
const renderButton = (buttonProps) => {
|
|
481
|
+
let { remainingTime, ...other } = buttonProps;
|
|
482
|
+
return resendotpLoading ? (jsxs("a", { className: clsx(classes.resendbtnLink, !btnshow && classes.btnvisibleoff), style: { cursor: "wait" }, children: [t("otp.GetNewOTP"), " ", jsx(CircularProgress, { size: 20, color: "secondary" })] })) : (jsx("a", { remainingtime: remainingTime, ...other, className: clsx(classes.resendbtnLink, !btnshow && classes.btnvisibleoff), children: t("otp.GetNewOTP") }));
|
|
483
|
+
};
|
|
484
|
+
const ClickEventHandler = () => {
|
|
485
|
+
if (!Boolean(OTP) || OTP.length < 6) {
|
|
486
|
+
setOTPError("otp.EnterOTPDigit");
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
489
|
+
setOTPError("");
|
|
490
|
+
VerifyOTP(OTP);
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
const handleResendClick = async () => {
|
|
494
|
+
setResendotpLoading(true);
|
|
495
|
+
const { status, data, message } = await OTPResendRequest(resendFlag === "FORGET_PW"
|
|
496
|
+
? loginState?.requestCd
|
|
497
|
+
: loginState?.transactionID, loginState?.username, resendFlag, loginState?.company_ID, loginState?.branch_cd);
|
|
498
|
+
setResendotpLoading(false);
|
|
499
|
+
if (status === "0") {
|
|
500
|
+
setNewRequestID(data?.TRAN_CD);
|
|
501
|
+
setbtnshow(false);
|
|
502
|
+
enqueueSnackbar(message, { variant: "success" });
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
enqueueSnackbar(message, { variant: "error" });
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
const handleCloseEvent = () => {
|
|
509
|
+
setOTPError("");
|
|
510
|
+
setOTP("");
|
|
511
|
+
handleClose();
|
|
512
|
+
};
|
|
513
|
+
const renderTime = (remainingtime) => {
|
|
514
|
+
if (parseInt(remainingtime) === 0) {
|
|
515
|
+
setTimeout(() => {
|
|
516
|
+
setbtnshow(true);
|
|
517
|
+
}, 700);
|
|
518
|
+
}
|
|
519
|
+
return (jsxs("span", { className: clsx(btnshow && classes.btnvisibleoff), children: [t("otp.OtpExpired"), " ", remainingtime] }));
|
|
520
|
+
};
|
|
521
|
+
useEffect(() => {
|
|
522
|
+
if (loginState?.otpmodelClose ?? false) {
|
|
523
|
+
handleCloseEvent();
|
|
524
|
+
}
|
|
525
|
+
}, [loginState.otpmodelClose]);
|
|
526
|
+
return (jsx(Fragment, { children: jsx(Grid, { alignItems: "center", children: jsxs("div", { children: [jsx("div", { style: {
|
|
527
|
+
color: "#000000",
|
|
528
|
+
fontSize: "30px",
|
|
529
|
+
fontWeight: "600",
|
|
530
|
+
// fontFamily: "Poppins",
|
|
531
|
+
alignItems: "center",
|
|
532
|
+
fontStyle: "normal",
|
|
533
|
+
lineHeight: "150%",
|
|
534
|
+
marginBottom: "10px",
|
|
535
|
+
}, children: t("otp.OTPAuthentication") }), jsxs("div", { className: classes.OTPalignName, children: [t("otp.Hello"), " ", loginState?.username
|
|
536
|
+
? loginState.username.charAt(0).toUpperCase() +
|
|
537
|
+
loginState.username.slice(1)
|
|
538
|
+
: null, loginState.otploading ||
|
|
539
|
+
otpresendCount >= 3 ||
|
|
540
|
+
loginState?.auth_type === "TOTP" ? null : (jsx(ResendOTP, { onResendClick: handleResendClick,
|
|
541
|
+
// onTimerComplete={() => setbtnshow(true)}
|
|
542
|
+
renderButton: renderButton, renderTime: renderTime, maxTime: loginState?.otpValidFor ?? 60, className: classes.resendOTPalign }))] }), jsxs("div", { className: classes.divflex, onKeyDown: (e) => {
|
|
543
|
+
if (e.key === "Enter") {
|
|
544
|
+
inputButtonRef?.current?.click?.();
|
|
545
|
+
}
|
|
546
|
+
}, children: [jsx(OTPInput, { value: OTP, onChange: setOTP, autoFocus: true, OTPLength: 6, otpType: "number", disabled: false, secure: !showPassword, className: classes.otpinputpadding }), jsx(IconButton$1, { "aria-label": "toggle password visibility", onClick: () => {
|
|
547
|
+
if (!showPassword) {
|
|
548
|
+
setShowPasswordTime(Date.now() + 5000);
|
|
549
|
+
timerRef.current = setTimeout(() => forceUpdate(Date.now()), 5000);
|
|
550
|
+
}
|
|
551
|
+
else if (showPassword)
|
|
552
|
+
setShowPasswordTime(0);
|
|
553
|
+
}, onMouseDown: (e) => e.preventDefault(), disabled: loginState.otploading, className: classes.ibtnvisible, children: showPassword ? jsx(Visibility, {}) : jsx(VisibilityOff, {}) })] }), Boolean(OTPError) ? (jsx(FormHelperText, { style: { color: "red" }, children: OTPError })) : null, loginState?.auth_type === "TOTP" ? (jsx("div", { style: { flex: "auto" }, children: jsx("a", { href: "forgot-totp", style: { color: "var(--theme-color3)" }, children: "Forgot TOTP" }) })) : (jsx(Fragment$1, {})), jsxs("div", { style: {
|
|
554
|
+
display: "flex",
|
|
555
|
+
gap: "10px",
|
|
556
|
+
margin: "42px 0 0 42px",
|
|
557
|
+
width: "60%",
|
|
558
|
+
}, children: [jsx(GradientButton, { fullWidth: true, disabled: loginState.otploading, onClick: handleCloseEvent, className: classes.otpButtons,
|
|
559
|
+
// starticon={"West"}
|
|
560
|
+
// color={"var(--theme-color2) !important"}
|
|
561
|
+
// rotateIcon="scale(1.4) rotateX(360deg)"
|
|
562
|
+
style: {
|
|
563
|
+
border: "var(--theme-color3)1px solid",
|
|
564
|
+
color: "var(--theme-color2)",
|
|
565
|
+
// background: "var(--theme-color2)",
|
|
566
|
+
borderRadius: "10px",
|
|
567
|
+
minWidth: "48%",
|
|
568
|
+
}, children: t("otp.Back") }), jsx(GradientButton, { style: {
|
|
569
|
+
borderRadius: loginState.otploading ? "50%" : "10px",
|
|
570
|
+
height: loginState.otploading ? "40px" : "100%",
|
|
571
|
+
width: loginState.otploading ? "0px" : "100%",
|
|
572
|
+
minWidth: loginState.otploading ? "40px" : "80px",
|
|
573
|
+
},
|
|
574
|
+
// fullWidth
|
|
575
|
+
disabled: loginState.loading, onClick: ClickEventHandler, ref: inputButtonRef, className: classes.otpButtons, children: loginState.otploading ? (jsx(CircularProgress, { size: 25, thickness: 4.6 })) : (t("otp.VerifyOTP")) })] })] }) }) }));
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
function styleInject(css, ref) {
|
|
579
|
+
if ( ref === void 0 ) ref = {};
|
|
580
|
+
var insertAt = ref.insertAt;
|
|
581
|
+
|
|
582
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
583
|
+
|
|
584
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
585
|
+
var style = document.createElement('style');
|
|
586
|
+
style.type = 'text/css';
|
|
587
|
+
|
|
588
|
+
if (insertAt === 'top') {
|
|
589
|
+
if (head.firstChild) {
|
|
590
|
+
head.insertBefore(style, head.firstChild);
|
|
591
|
+
} else {
|
|
592
|
+
head.appendChild(style);
|
|
593
|
+
}
|
|
594
|
+
} else {
|
|
595
|
+
head.appendChild(style);
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
if (style.styleSheet) {
|
|
599
|
+
style.styleSheet.cssText = css;
|
|
600
|
+
} else {
|
|
601
|
+
style.appendChild(document.createTextNode(css));
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
var css_248z = ".spinner-wrap{position:relative}.spinner-item{animation:zoom 2s linear .75s infinite;border:1px solid #949597;border-radius:50%;height:250px;left:50%;opacity:0;position:absolute;top:50%;transform:translate(-50%,-50%);width:250px}.spinner-item--2{animation-delay:1.25s}.spinner-item--3{animation-delay:1.75s}@keyframes zoom{0%{opacity:0;transform:translate(-50%,-50%) scale(.1)}50%{opacity:1}to{opacity:0;transform:translate(-50%,-50%) scale(.6)}}.image{height:50px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}.progress{backdrop-filter:blur(2px) brightness(101%);border:1px solid #b0b0b0;border-radius:4px;box-shadow:0 0 3px #b0b0;margin:0 auto;width:20em}.bar{background:#4263c7;height:4px;width:65%}";
|
|
606
|
+
styleInject(css_248z);
|
|
607
|
+
|
|
608
|
+
const VerifyFinger = ({ classes, loginState, verifyFinger, previousStep, }) => {
|
|
609
|
+
const { t } = useTranslation();
|
|
610
|
+
return (jsx(Fragment, { children: jsx(Container, { maxWidth: "xs", children: jsxs(Grid, { alignItems: "center", children: [jsxs("div", { style: {
|
|
611
|
+
marginRight: "25px",
|
|
612
|
+
width: "102%",
|
|
613
|
+
// marginBottom: "55px",
|
|
614
|
+
}, children: [jsx("br", {}), jsx("div", { style: {
|
|
615
|
+
color: "#000000",
|
|
616
|
+
fontSize: "34px",
|
|
617
|
+
fontWeight: "600",
|
|
618
|
+
// fontFamily: "Poppins",
|
|
619
|
+
alignItems: "center",
|
|
620
|
+
fontStyle: "normal",
|
|
621
|
+
lineHeight: "150%",
|
|
622
|
+
marginBottom: "10px",
|
|
623
|
+
}, children: t("Biometric.BiometrixAuthentication") }), jsx("div", { style: {
|
|
624
|
+
color: "#949597",
|
|
625
|
+
fontSize: "18px",
|
|
626
|
+
fontWeight: "400",
|
|
627
|
+
// fontFamily: "Poppins",
|
|
628
|
+
alignItems: "center",
|
|
629
|
+
fontStyle: "normal",
|
|
630
|
+
lineHeight: "33px",
|
|
631
|
+
// marginBottom: "10px",
|
|
632
|
+
}, children: t("Biometric.Kindlyplaceyoufinger") }), jsx("br", {}), jsxs(Typography, { variant: "h5", style: { color: "#000000" }, children: [t("otp.Hello"), " ", "", ` ${loginState?.username
|
|
633
|
+
? loginState.username.charAt(0).toUpperCase() +
|
|
634
|
+
loginState.username.slice(1)
|
|
635
|
+
: null}`] }), jsx("br", {}), jsx("div", { className: loginState?.isBiometricError
|
|
636
|
+
? classes.eFingerUi
|
|
637
|
+
: classes.fingerUi, children: jsxs("div", { className: "spinner-wrap", children: [jsx(FingerprintSharpIcon, { sx: {
|
|
638
|
+
fontSize: "80px",
|
|
639
|
+
opacity: "0.4",
|
|
640
|
+
borderRadius: "50%",
|
|
641
|
+
display: "flex",
|
|
642
|
+
margin: "0 auto",
|
|
643
|
+
"&:after": {
|
|
644
|
+
borderBottom: "2px solid #26A456",
|
|
645
|
+
},
|
|
646
|
+
}, className: loginState?.isBiometricError ? classes.FingerIcon : null, color: loginState?.isBiometricError ? "error" : "inherit" }), loginState?.isScanning ? (jsxs(Fragment$1, { children: [jsx("div", { className: "spinner-item", style: {
|
|
647
|
+
border: loginState?.isScanning
|
|
648
|
+
? "1px solid #949597"
|
|
649
|
+
: " 1px solid red",
|
|
650
|
+
} }), jsx("div", { className: "spinner-item spinner-item--2", style: {
|
|
651
|
+
border: loginState?.isScanning
|
|
652
|
+
? "1px solid #949597"
|
|
653
|
+
: "1px solid red",
|
|
654
|
+
} }), jsx("div", { className: "spinner-item spinner-item--3", style: {
|
|
655
|
+
border: loginState?.isScanning
|
|
656
|
+
? "1px solid #949597"
|
|
657
|
+
: "1px solid red",
|
|
658
|
+
} })] })) : null] }) }), jsx("div", { className: classes.biometric, children: jsxs("div", { style: { marginTop: "50px" }, children: [jsx("div", { className: loginState.isScanning ? "progress" : "hide", children: jsx("div", { className: "bar", style: { width: loginState.isScanning ? "30%" : "0%" } }) }), jsx("h3", { style: {
|
|
659
|
+
display: "flex",
|
|
660
|
+
marginTop: "20px",
|
|
661
|
+
justifyContent: "space-around",
|
|
662
|
+
color: loginState?.isBiometricError
|
|
663
|
+
? "rgb(255 0 0 / 65%)"
|
|
664
|
+
: "inherit",
|
|
665
|
+
}, children: loginState?.isBiometricError
|
|
666
|
+
? loginState?.userMessage
|
|
667
|
+
: loginState?.loading
|
|
668
|
+
? t("Biometric.Loading")
|
|
669
|
+
: loginState?.isScanning
|
|
670
|
+
? t("Biometric.Scanning")
|
|
671
|
+
: null })] }) })] }), jsxs("div", { style: {
|
|
672
|
+
display: "flex",
|
|
673
|
+
justifyContent: "center",
|
|
674
|
+
margin: "42px 0 0 42px",
|
|
675
|
+
// margin: "38px 0 0 0",
|
|
676
|
+
gap: "10px",
|
|
677
|
+
}, children: [jsx(GradientButton, { fullWidth: true, disabled: loginState.loading, onClick: () => {
|
|
678
|
+
previousStep(false, "");
|
|
679
|
+
}, className: classes.otpButtons,
|
|
680
|
+
// starticon={"West"}
|
|
681
|
+
// rotateIcon="scale(1.4) rotateX(360deg)"
|
|
682
|
+
// color={"var(--theme-color3) !important"}
|
|
683
|
+
style: {
|
|
684
|
+
border: "var(--theme-color3)1px solid",
|
|
685
|
+
color: "var(--theme-color3)",
|
|
686
|
+
background: "var(--theme-color2)",
|
|
687
|
+
borderRadius: "10px",
|
|
688
|
+
minWidth: "48%",
|
|
689
|
+
}, children: t("otp.Back") }), jsx(GradientButton, { style: {
|
|
690
|
+
borderRadius: loginState.loading ? "50%" : "10px",
|
|
691
|
+
height: loginState.loading ? "40px" : "100%",
|
|
692
|
+
width: loginState.loading ? "0px" : "100%",
|
|
693
|
+
minWidth: loginState.loading ? "40px" : "80px",
|
|
694
|
+
// width: loginState.loading ? "0px" : "90%",
|
|
695
|
+
// minWidth: loginState.loading ? "40px" : "80px",
|
|
696
|
+
}, disabled: loginState.loading, onKeyDown: (e) => e.keyCode === 13 && verifyFinger, onClick: verifyFinger, className: classes.otpButtons, children: loginState.loading ? (jsx(CircularProgress, { size: 25, thickness: 4.6, style: { color: "#fff" } })) : (t("Biometric.Verify")) })] })] }) }) }));
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
const capture = async () => {
|
|
700
|
+
var MFS100Request = {
|
|
701
|
+
Quality: 60,
|
|
702
|
+
TimeOut: 10,
|
|
703
|
+
};
|
|
704
|
+
var jsondata = JSON.stringify(MFS100Request);
|
|
705
|
+
const rawResponse = await fetch("http://localhost:8004/mfs100/capture", {
|
|
706
|
+
method: "POST",
|
|
707
|
+
headers: {
|
|
708
|
+
Accept: "application/json",
|
|
709
|
+
"Content-Type": "application/json",
|
|
710
|
+
},
|
|
711
|
+
body: jsondata,
|
|
712
|
+
});
|
|
713
|
+
const content = await rawResponse.json();
|
|
714
|
+
return content;
|
|
715
|
+
};
|
|
716
|
+
|
|
717
|
+
const decryptString = (encryptString) => {
|
|
718
|
+
var secretKey = "SUPERACUTE@MKS";
|
|
719
|
+
var keyBytes = CryptoJS.PBKDF2(secretKey, "Ivan Medvedev", {
|
|
720
|
+
keySize: 48 / 4,
|
|
721
|
+
iterations: 1000,
|
|
722
|
+
});
|
|
723
|
+
console.log(keyBytes.toString());
|
|
724
|
+
// take first 32 bytes as key (like in C# code)
|
|
725
|
+
var key = new CryptoJS.lib.WordArray.init(keyBytes.words, 32);
|
|
726
|
+
// // skip first 32 bytes and take next 16 bytes as IV
|
|
727
|
+
var iv = new CryptoJS.lib.WordArray.init(keyBytes.words.splice(32 / 4), 16);
|
|
728
|
+
// console.log(key.toString());
|
|
729
|
+
//console.log(encryptString, CryptoJS.enc.Base64.parse(encryptString));
|
|
730
|
+
var dec = CryptoJS.AES.decrypt({
|
|
731
|
+
ciphertext: CryptoJS.enc.Base64.parse(CryptoJS.enc.Base64.parse(encryptString).toString(CryptoJS.enc.Utf8)),
|
|
732
|
+
}, key, {
|
|
733
|
+
iv: iv,
|
|
734
|
+
});
|
|
735
|
+
console.log("CryptoJS.AES.decrypt", dec);
|
|
736
|
+
return dec.toString(CryptoJS.enc.Utf8).split(String.fromCharCode(0)).join("");
|
|
737
|
+
};
|
|
738
|
+
const matchFinger = async (rows, captureFinger) => {
|
|
739
|
+
var promise = new Promise((resolve, reject) => {
|
|
740
|
+
//console.log("matchFinger", rows, typeof rows);
|
|
741
|
+
if (typeof rows === "string") {
|
|
742
|
+
rows = JSON.parse(rows);
|
|
743
|
+
}
|
|
744
|
+
rows.forEach(async (element, i) => {
|
|
745
|
+
try {
|
|
746
|
+
var galleryTemplate = decryptString(element.IMG_DATA);
|
|
747
|
+
var MFS100Request = {
|
|
748
|
+
GalleryTemplate: galleryTemplate,
|
|
749
|
+
ProbTemplate: captureFinger,
|
|
750
|
+
BioType: "Iso",
|
|
751
|
+
};
|
|
752
|
+
var jsondata = JSON.stringify(MFS100Request);
|
|
753
|
+
await fetch("http://localhost:8004/mfs100/verify", {
|
|
754
|
+
method: "POST",
|
|
755
|
+
headers: {
|
|
756
|
+
Accept: "application/json",
|
|
757
|
+
"Content-Type": "application/json",
|
|
758
|
+
},
|
|
759
|
+
body: jsondata,
|
|
760
|
+
})
|
|
761
|
+
.then((response) => response.json())
|
|
762
|
+
.then((response) => {
|
|
763
|
+
if (response?.ErrorCode === "0" && response["Status"]) {
|
|
764
|
+
resolve({
|
|
765
|
+
status: true,
|
|
766
|
+
errorCode: "0",
|
|
767
|
+
errorMessage: "",
|
|
768
|
+
isError: false,
|
|
769
|
+
sr_cd: element.SR_CD,
|
|
770
|
+
});
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
if (rows.length === i + 1) {
|
|
774
|
+
resolve({
|
|
775
|
+
status: false,
|
|
776
|
+
errorCode: response.ErrorCode,
|
|
777
|
+
errorMessage: response.ErrorMessage,
|
|
778
|
+
isError: false,
|
|
779
|
+
});
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
})
|
|
783
|
+
.catch((reason) => {
|
|
784
|
+
resolve({
|
|
785
|
+
status: false,
|
|
786
|
+
errorCode: "999",
|
|
787
|
+
errorMessage: reason,
|
|
788
|
+
isError: true,
|
|
789
|
+
});
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
catch (err) {
|
|
793
|
+
console.log(err);
|
|
794
|
+
resolve({
|
|
795
|
+
status: false,
|
|
796
|
+
errorCode: "999",
|
|
797
|
+
errorMessage: "Something went wrong!",
|
|
798
|
+
isError: true,
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
});
|
|
802
|
+
});
|
|
803
|
+
return promise;
|
|
804
|
+
};
|
|
805
|
+
|
|
806
|
+
const BankDetails = ({ bannerDetails }) => {
|
|
807
|
+
const [loginImageURL, setLoginImageURL] = useState(null);
|
|
808
|
+
const urlObj = useRef(null);
|
|
809
|
+
const classes = useStyles();
|
|
810
|
+
useNavigate();
|
|
811
|
+
// let path = require("assets/sound/successSound.mp3").default;
|
|
812
|
+
// let audio = new Audio(path);
|
|
813
|
+
// useEffect(() => {
|
|
814
|
+
// if (isLoggedIn()) {
|
|
815
|
+
// navigate("/cbsenfinity", { replace: true });
|
|
816
|
+
// }
|
|
817
|
+
// }, [navigate, isLoggedIn]);
|
|
818
|
+
const banner = useMemo(() => bannerDetails, []);
|
|
819
|
+
useEffect(() => {
|
|
820
|
+
if (Boolean(banner.bannerImg)) {
|
|
821
|
+
let blob = utilFunction.base64toBlob(banner.bannerImg);
|
|
822
|
+
urlObj.current =
|
|
823
|
+
typeof blob === "object" && Boolean(blob)
|
|
824
|
+
? URL.createObjectURL(blob)
|
|
825
|
+
: "";
|
|
826
|
+
setLoginImageURL(urlObj.current);
|
|
827
|
+
}
|
|
828
|
+
}, [banner]);
|
|
829
|
+
return (jsx(Fragment$1, { children: jsxs(Grid, { item: true, xs: 6, md: 6, lg: 6, className: classes.loginLeft, children: [jsx(Grid, { item: true, xs: 12, md: 12, lg: 12, style: { height: "70vh" }, children: jsx("img", { alt: "", style: {
|
|
830
|
+
width: "100%",
|
|
831
|
+
height: "100%",
|
|
832
|
+
objectFit: "cover",
|
|
833
|
+
objectPosition: "center",
|
|
834
|
+
}, src: Boolean(loginImageURL) ? loginImageURL : "" }) }), jsx(Grid, { item: true, xs: 12, md: 12, lg: 12, style: {
|
|
835
|
+
height: "30vh",
|
|
836
|
+
background: "var(--theme-color5)",
|
|
837
|
+
}, children: jsxs(Container, { maxWidth: "sm", children: [jsxs("div", { className: "text", style: {
|
|
838
|
+
color: "white",
|
|
839
|
+
fontStyle: "normal",
|
|
840
|
+
fontSize: "35px",
|
|
841
|
+
paddingTop: "30px",
|
|
842
|
+
}, children: [banner.bannerTitle ?? "", jsx("span", { style: { marginLeft: "8px", fontWeight: "900" } })] }), jsx("div", { style: {
|
|
843
|
+
lineHeight: "27px",
|
|
844
|
+
fontSize: "15px",
|
|
845
|
+
fontWeight: "500px",
|
|
846
|
+
letterSpacing: "0.02em",
|
|
847
|
+
color: "#ebedee",
|
|
848
|
+
maxWidth: "464px",
|
|
849
|
+
}, children: banner.bannerNote ?? "" })] }) })] }) }));
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
const PasswordRotation = ({ classes, ResetPassword, open, username, accessToken, tokenType, handleClose, }) => {
|
|
853
|
+
const inputButtonRef = useRef(null);
|
|
854
|
+
const { enqueueSnackbar } = useSnackbar();
|
|
855
|
+
const { t } = useTranslation();
|
|
856
|
+
const [input, setInput] = useState({
|
|
857
|
+
userName: username,
|
|
858
|
+
oldpassword: "",
|
|
859
|
+
password: "",
|
|
860
|
+
confirmpassword: "",
|
|
861
|
+
});
|
|
862
|
+
const [pwdReset, setPasswordReset] = useState({
|
|
863
|
+
isError: false,
|
|
864
|
+
errorMessage: "",
|
|
865
|
+
isLoading: false,
|
|
866
|
+
isoldPwdError: false,
|
|
867
|
+
oldpassworderror: "",
|
|
868
|
+
isnewpwdError: false,
|
|
869
|
+
newpassworderror: "",
|
|
870
|
+
isconfirmnewpwdError: false,
|
|
871
|
+
confirmnewpassworderror: "",
|
|
872
|
+
});
|
|
873
|
+
const handleCloseEvent = () => {
|
|
874
|
+
handleClose("");
|
|
875
|
+
};
|
|
876
|
+
const ClickEventHandler = async () => {
|
|
877
|
+
let isError = false;
|
|
878
|
+
let setPwdData = {
|
|
879
|
+
isError: false,
|
|
880
|
+
errorMessage: "",
|
|
881
|
+
isLoading: false,
|
|
882
|
+
isoldPwdError: false,
|
|
883
|
+
oldpassworderror: "",
|
|
884
|
+
isnewpwdError: false,
|
|
885
|
+
newpassworderror: "",
|
|
886
|
+
isconfirmnewpwdError: false,
|
|
887
|
+
confirmnewpassworderror: "",
|
|
888
|
+
};
|
|
889
|
+
if (!Boolean(input.oldpassword)) {
|
|
890
|
+
setPwdData.isoldPwdError = true;
|
|
891
|
+
setPwdData.oldpassworderror = "Current Password is required.";
|
|
892
|
+
isError = true;
|
|
893
|
+
}
|
|
894
|
+
let pwdData = utilFunction.ValidatePassword(input.password);
|
|
895
|
+
if (Boolean(pwdData)) {
|
|
896
|
+
setPwdData.isnewpwdError = true;
|
|
897
|
+
setPwdData.newpassworderror = pwdData;
|
|
898
|
+
isError = true;
|
|
899
|
+
}
|
|
900
|
+
if (Boolean(input.oldpassword) &&
|
|
901
|
+
Boolean(input.password) &&
|
|
902
|
+
input.oldpassword === input.password) {
|
|
903
|
+
setPwdData.isnewpwdError = true;
|
|
904
|
+
setPwdData.newpassworderror =
|
|
905
|
+
"The new password cannot be the same as the old password";
|
|
906
|
+
isError = true;
|
|
907
|
+
}
|
|
908
|
+
if (!Boolean(input.confirmpassword)) {
|
|
909
|
+
setPwdData.isconfirmnewpwdError = true;
|
|
910
|
+
setPwdData.confirmnewpassworderror = "Confirm new password is required.";
|
|
911
|
+
isError = true;
|
|
912
|
+
}
|
|
913
|
+
else if (Boolean(input.password) &&
|
|
914
|
+
input.password !== input.confirmpassword) {
|
|
915
|
+
setPwdData.isconfirmnewpwdError = true;
|
|
916
|
+
setPwdData.confirmnewpassworderror =
|
|
917
|
+
"New Password and Confirm Password did not matched";
|
|
918
|
+
isError = true;
|
|
919
|
+
}
|
|
920
|
+
if (isError) {
|
|
921
|
+
setPasswordReset(setPwdData);
|
|
922
|
+
}
|
|
923
|
+
else {
|
|
924
|
+
setPasswordReset((values) => ({ ...values, isLoading: true }));
|
|
925
|
+
let response = await ResetPassword(input.userName, input.oldpassword, input.password, accessToken, tokenType);
|
|
926
|
+
setPasswordReset((values) => ({ ...values, isLoading: false }));
|
|
927
|
+
if (response.status === "0") {
|
|
928
|
+
enqueueSnackbar("Password successfully changed.", {
|
|
929
|
+
variant: "success",
|
|
930
|
+
});
|
|
931
|
+
handleClose("0");
|
|
932
|
+
}
|
|
933
|
+
else {
|
|
934
|
+
setPasswordReset((values) => ({
|
|
935
|
+
...values,
|
|
936
|
+
isError: true,
|
|
937
|
+
errorMessage: response.message,
|
|
938
|
+
}));
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
};
|
|
942
|
+
const handleChange = (event) => {
|
|
943
|
+
const name = event.target.name;
|
|
944
|
+
let value = event.target.value;
|
|
945
|
+
if (name === "oldpassword" && Boolean(value)) {
|
|
946
|
+
setPasswordReset((values) => ({ ...values, isoldPwdError: false }));
|
|
947
|
+
}
|
|
948
|
+
else if (name === "password" && Boolean(value)) {
|
|
949
|
+
setPasswordReset((values) => ({ ...values, isnewpwdError: false }));
|
|
950
|
+
}
|
|
951
|
+
else if (name === "confirmpassword" && Boolean(value)) {
|
|
952
|
+
setPasswordReset((values) => ({
|
|
953
|
+
...values,
|
|
954
|
+
isconfirmnewpwdError: false,
|
|
955
|
+
}));
|
|
956
|
+
}
|
|
957
|
+
setInput((values) => ({ ...values, [name]: value }));
|
|
958
|
+
};
|
|
959
|
+
return (jsx(Fragment, { children: jsx(Container, { maxWidth: "xs", children: jsxs(Grid, { alignItems: "center", children: [jsx("div", { style: {
|
|
960
|
+
color: "#000000 !important",
|
|
961
|
+
fontSize: "30px",
|
|
962
|
+
fontWeight: "600",
|
|
963
|
+
alignItems: "center",
|
|
964
|
+
fontStyle: "normal",
|
|
965
|
+
}, children: jsx("h3", { children: "Password Rotation" }) }), jsx("div", { className: "", style: {
|
|
966
|
+
color: "#949597",
|
|
967
|
+
fontSize: "18px",
|
|
968
|
+
fontWeight: "400",
|
|
969
|
+
alignItems: "center",
|
|
970
|
+
fontStyle: "normal",
|
|
971
|
+
width: "360px",
|
|
972
|
+
}, children: "Please Verify OTP" }), jsxs("div", { className: classes.formWrap, children: [jsx(TextField, { label: "User ID", placeholder: "Enter User ID", fullWidth: true, type: "text", name: "userName", value: input.userName || "", onChange: handleChange, InputLabelProps: { shrink: true }, disabled: true, autoComplete: "off", inputProps: { maxLength: 16 }, style: { paddingBottom: "8px" } }), jsx(TextField, { autoFocus: true, label: "Current Password", placeholder: "Enter Current Password", fullWidth: true, type: "password", name: "oldpassword", value: input.oldpassword || "", onChange: handleChange, error: pwdReset.isoldPwdError, helperText: pwdReset.isoldPwdError ? t(pwdReset.oldpassworderror) : "", InputLabelProps: { shrink: true }, disabled: pwdReset.isLoading, autoComplete: "off", onKeyDown: (e) => {
|
|
973
|
+
if (e.key === "Enter") {
|
|
974
|
+
inputButtonRef?.current?.click?.();
|
|
975
|
+
}
|
|
976
|
+
}, inputProps: { maxLength: 16 }, style: { paddingBottom: "8px" } }), jsx(TextField, { label: "New Password", placeholder: "Enter New Password", fullWidth: true, type: "password", name: "password", value: input.password || "", onChange: handleChange, error: pwdReset.isnewpwdError, helperText: pwdReset.isnewpwdError ? t(pwdReset.newpassworderror) : "", InputLabelProps: { shrink: true }, disabled: pwdReset.isLoading, autoComplete: "off", onKeyDown: (e) => {
|
|
977
|
+
if (e.key === "Enter") {
|
|
978
|
+
inputButtonRef?.current?.click?.();
|
|
979
|
+
}
|
|
980
|
+
}, inputProps: { maxLength: 16 }, style: { paddingBottom: "8px" } }), jsx(TextField, { label: "Confirm New Password", placeholder: "Enter confirm new password", fullWidth: true, type: "password", name: "confirmpassword", value: input.confirmpassword || "", onChange: handleChange, error: pwdReset.isconfirmnewpwdError, helperText: pwdReset.isconfirmnewpwdError
|
|
981
|
+
? t(pwdReset.confirmnewpassworderror)
|
|
982
|
+
: "", InputLabelProps: { shrink: true }, disabled: pwdReset.isLoading, autoComplete: "off", onKeyDown: (e) => {
|
|
983
|
+
if (e.key === "Enter") {
|
|
984
|
+
inputButtonRef?.current?.click?.();
|
|
985
|
+
}
|
|
986
|
+
}, inputProps: { maxLength: 16 }, style: { paddingBottom: "8px" } }), pwdReset.isError ? (jsx(FormHelperText, { style: { color: "red" }, children: pwdReset.errorMessage })) : null] }), jsxs("div", { style: {
|
|
987
|
+
display: "flex",
|
|
988
|
+
gap: "10px",
|
|
989
|
+
margin: "20px 0 0 10px",
|
|
990
|
+
width: "94%",
|
|
991
|
+
}, children: [jsx(GradientButton, { fullWidth: true, disabled: pwdReset.isLoading, onClick: handleCloseEvent, className: classes.otpButtons, style: {
|
|
992
|
+
border: "var(--theme-color3)1px solid",
|
|
993
|
+
color: "var(--theme-color3)",
|
|
994
|
+
// pebbackground: "var(--theme-color2)",
|
|
995
|
+
borderRadius: "10px",
|
|
996
|
+
}, children: "Back" }), jsx(GradientButton, { style: {
|
|
997
|
+
borderRadius: pwdReset.isLoading ? "50%" : "10px",
|
|
998
|
+
height: pwdReset.isLoading ? "40px" : "100%",
|
|
999
|
+
width: pwdReset.isLoading ? "0px" : "100%",
|
|
1000
|
+
minWidth: pwdReset.isLoading ? "40px" : "80px",
|
|
1001
|
+
}, fullWidth: true, disabled: pwdReset.isLoading, onClick: ClickEventHandler, ref: inputButtonRef, className: classes.otpButtons, children: pwdReset.isLoading ? (jsx(CircularProgress, { size: 25, thickness: 4.6 })) : ("Update") })] })] }) }) }));
|
|
1002
|
+
};
|
|
1003
|
+
|
|
1004
|
+
const inititalState = {
|
|
1005
|
+
username: "",
|
|
1006
|
+
firstName: "",
|
|
1007
|
+
lastName: "",
|
|
1008
|
+
loading: false,
|
|
1009
|
+
otploading: false,
|
|
1010
|
+
isError: false,
|
|
1011
|
+
isUsernameError: false,
|
|
1012
|
+
isPasswordError: false,
|
|
1013
|
+
userMessage: "",
|
|
1014
|
+
OtpuserMessage: "",
|
|
1015
|
+
userMessageforpassword: "",
|
|
1016
|
+
userMessageforusername: "",
|
|
1017
|
+
currentFlow: "username",
|
|
1018
|
+
transactionID: "",
|
|
1019
|
+
access_token: "",
|
|
1020
|
+
token_type: "",
|
|
1021
|
+
otpmodelClose: false,
|
|
1022
|
+
authType: "",
|
|
1023
|
+
isScanning: false,
|
|
1024
|
+
auth_data: [],
|
|
1025
|
+
company_ID: "",
|
|
1026
|
+
Branch_CD: "",
|
|
1027
|
+
auth_type: "O",
|
|
1028
|
+
otpValidFor: 60,
|
|
1029
|
+
};
|
|
1030
|
+
const reducer = (state, action) => {
|
|
1031
|
+
switch (action.type) {
|
|
1032
|
+
case "inititateUserFingerVerification":
|
|
1033
|
+
case "inititateOTPVerification": {
|
|
1034
|
+
return {
|
|
1035
|
+
...state,
|
|
1036
|
+
loading: true,
|
|
1037
|
+
isError: false,
|
|
1038
|
+
isUsernameError: false,
|
|
1039
|
+
isPasswordError: false,
|
|
1040
|
+
isOTPError: false,
|
|
1041
|
+
isBiometricError: false,
|
|
1042
|
+
userMessage: "",
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
case "inititateUserFingerScanner": {
|
|
1046
|
+
return { ...state, isScanning: true, isBiometricError: false };
|
|
1047
|
+
}
|
|
1048
|
+
case "usernameandpasswordrequired": {
|
|
1049
|
+
return {
|
|
1050
|
+
...state,
|
|
1051
|
+
loading: false,
|
|
1052
|
+
isError: true,
|
|
1053
|
+
isUsernameError: true,
|
|
1054
|
+
isPasswordError: true,
|
|
1055
|
+
otploading: false,
|
|
1056
|
+
userMessage: action?.payload?.error,
|
|
1057
|
+
userMessageforpassword: action?.payload?.errorPassword,
|
|
1058
|
+
userMessageforusername: action?.payload?.errorUsername,
|
|
1059
|
+
username: "",
|
|
1060
|
+
transactionID: "",
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
case "passwordVerificationFailure":
|
|
1064
|
+
return {
|
|
1065
|
+
...state,
|
|
1066
|
+
loading: false,
|
|
1067
|
+
isError: true,
|
|
1068
|
+
isUsernameError: false,
|
|
1069
|
+
isPasswordError: true,
|
|
1070
|
+
otploading: false,
|
|
1071
|
+
userMessage: action?.payload?.error,
|
|
1072
|
+
userMessageforpassword: action?.payload?.errorPassword,
|
|
1073
|
+
username: "",
|
|
1074
|
+
transactionID: "",
|
|
1075
|
+
};
|
|
1076
|
+
case "usernameVerificationFailure": {
|
|
1077
|
+
return {
|
|
1078
|
+
...state,
|
|
1079
|
+
loading: false,
|
|
1080
|
+
isError: true,
|
|
1081
|
+
isUsernameError: true,
|
|
1082
|
+
isPasswordError: false,
|
|
1083
|
+
otploading: false,
|
|
1084
|
+
userMessage: action?.payload?.error,
|
|
1085
|
+
userMessageforusername: action?.payload?.errorUsername,
|
|
1086
|
+
username: "",
|
|
1087
|
+
transactionID: "",
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
case "inititatePasswordVerification": {
|
|
1091
|
+
return {
|
|
1092
|
+
...state,
|
|
1093
|
+
loading: true,
|
|
1094
|
+
isError: false,
|
|
1095
|
+
isUsernameError: false,
|
|
1096
|
+
isPasswordError: false,
|
|
1097
|
+
otploading: false,
|
|
1098
|
+
userMessage: "",
|
|
1099
|
+
userMessageforusername: "",
|
|
1100
|
+
userMessageforpassword: "",
|
|
1101
|
+
username: "",
|
|
1102
|
+
transactionID: "",
|
|
1103
|
+
access_token: "",
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
case "passwordRotation": {
|
|
1107
|
+
return {
|
|
1108
|
+
...state,
|
|
1109
|
+
loading: false,
|
|
1110
|
+
username: action?.payload?.username,
|
|
1111
|
+
access_token: action?.payload?.access_token,
|
|
1112
|
+
token_type: action?.payload?.token_type,
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
case "passwordRotationsuccess": {
|
|
1116
|
+
return {
|
|
1117
|
+
...state,
|
|
1118
|
+
loading: false,
|
|
1119
|
+
otpmodelClose: Boolean(action?.payload?.otpmodelclose),
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
case "passwordVerificationSuccessful": {
|
|
1123
|
+
return {
|
|
1124
|
+
...state,
|
|
1125
|
+
loading: false,
|
|
1126
|
+
otploading: false,
|
|
1127
|
+
transactionID: action?.payload?.transactionID,
|
|
1128
|
+
username: action?.payload?.username,
|
|
1129
|
+
auth_type: action?.payload?.auth_type,
|
|
1130
|
+
OtpuserMessage: "",
|
|
1131
|
+
access_token: action?.payload?.access_token,
|
|
1132
|
+
token_type: action?.payload?.token_type,
|
|
1133
|
+
otpmodelClose: false,
|
|
1134
|
+
currentFlow: "OTP",
|
|
1135
|
+
authType: action?.payload?.authType,
|
|
1136
|
+
auth_data: action?.payload?.auth_data,
|
|
1137
|
+
otpValidFor: action?.payload?.otpValidFor,
|
|
1138
|
+
company_ID: action?.paylod?.company_ID,
|
|
1139
|
+
};
|
|
1140
|
+
}
|
|
1141
|
+
case "inititatebiometricVerification": {
|
|
1142
|
+
return {
|
|
1143
|
+
...state,
|
|
1144
|
+
loading: true,
|
|
1145
|
+
otploading: true,
|
|
1146
|
+
OtpuserMessage: "",
|
|
1147
|
+
otpmodelClose: false,
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
case "biometricVerificationFailure":
|
|
1151
|
+
return {
|
|
1152
|
+
...state,
|
|
1153
|
+
loading: false,
|
|
1154
|
+
isError: true,
|
|
1155
|
+
isBiometricError: true,
|
|
1156
|
+
userMessage: action?.payload?.error,
|
|
1157
|
+
isScanning: false,
|
|
1158
|
+
};
|
|
1159
|
+
case "biometricVerificationSuccessful":
|
|
1160
|
+
return {
|
|
1161
|
+
...state,
|
|
1162
|
+
loading: false,
|
|
1163
|
+
isError: false,
|
|
1164
|
+
isBiometricError: false,
|
|
1165
|
+
state: action.payload,
|
|
1166
|
+
isScanning: false,
|
|
1167
|
+
};
|
|
1168
|
+
case "OTPVerificationComplate": {
|
|
1169
|
+
return {
|
|
1170
|
+
...state,
|
|
1171
|
+
loading: false,
|
|
1172
|
+
otploading: false,
|
|
1173
|
+
OtpuserMessage: "",
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1176
|
+
case "OTPVerificationFailed": {
|
|
1177
|
+
return {
|
|
1178
|
+
...state,
|
|
1179
|
+
loading: false,
|
|
1180
|
+
otploading: false,
|
|
1181
|
+
OtpuserMessage: action?.payload?.error,
|
|
1182
|
+
otpmodelClose: Boolean(action?.payload?.otpmodelclose),
|
|
1183
|
+
};
|
|
1184
|
+
}
|
|
1185
|
+
case "OTPResendSuccess": {
|
|
1186
|
+
return {
|
|
1187
|
+
...state,
|
|
1188
|
+
transactionID: action?.payload?.transactionID,
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
1191
|
+
case "backToUsernameVerification": {
|
|
1192
|
+
return {
|
|
1193
|
+
...inititalState,
|
|
1194
|
+
isPasswordError: action?.payload?.isError,
|
|
1195
|
+
userMessageforpassword: action?.payload?.errorMessage,
|
|
1196
|
+
};
|
|
1197
|
+
}
|
|
1198
|
+
default: {
|
|
1199
|
+
return state;
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
};
|
|
1203
|
+
const AuthControllerWrapper = ({ bannerDetails, logoUrl, loading, loginFn, veirfyUsernameandPassword, verifyOTP, OTPResendRequest, ResetPassword, }) => {
|
|
1204
|
+
// const { isLoggedIn, login } = useContext(AuthContext);
|
|
1205
|
+
const classes = useStyles();
|
|
1206
|
+
useNavigate();
|
|
1207
|
+
const [loginState, dispath] = useReducer(reducer, inititalState);
|
|
1208
|
+
const [openpwdreset, setOpenPwdReset] = useState(false);
|
|
1209
|
+
const failureCount = useRef(0);
|
|
1210
|
+
const [dashboardLogoURL, setDashboardLogoURL] = useState(null);
|
|
1211
|
+
const urlObj = useRef(null);
|
|
1212
|
+
const { t } = useTranslation();
|
|
1213
|
+
const otpResendRef = useRef(1);
|
|
1214
|
+
// useEffect(() => {
|
|
1215
|
+
// if (isLoggedIn()) {
|
|
1216
|
+
// navigate("/cbsenfinity", { replace: true });
|
|
1217
|
+
// }
|
|
1218
|
+
// }, [navigate, isLoggedIn]);
|
|
1219
|
+
// const {
|
|
1220
|
+
// data: imageData,
|
|
1221
|
+
// isLoading,
|
|
1222
|
+
// isFetching,
|
|
1223
|
+
// } = useQuery<any, any>(["getLoginImageData"], () =>
|
|
1224
|
+
// API.getLoginImageData({ APP_TRAN_CD: "51" })
|
|
1225
|
+
// );
|
|
1226
|
+
// const imageDataString = JSON.stringify(imageData);
|
|
1227
|
+
// localStorage.setItem("imageData", imageDataString);
|
|
1228
|
+
// const imageDataFromStorage: any = localStorage.getItem("imageData");
|
|
1229
|
+
useEffect(() => {
|
|
1230
|
+
if (Boolean(logoUrl)) {
|
|
1231
|
+
let blob = utilFunction.base64toBlob(logoUrl);
|
|
1232
|
+
urlObj.current =
|
|
1233
|
+
typeof blob === "object" && Boolean(blob)
|
|
1234
|
+
? URL.createObjectURL(blob)
|
|
1235
|
+
: "";
|
|
1236
|
+
setDashboardLogoURL(urlObj.current);
|
|
1237
|
+
}
|
|
1238
|
+
}, [logoUrl]);
|
|
1239
|
+
// useEffect(() => {
|
|
1240
|
+
// GeneralAPI.setDocumentName("Enfinity");
|
|
1241
|
+
// }, []);
|
|
1242
|
+
const verifyUsernamePassword = async (username, password) => {
|
|
1243
|
+
if (Boolean(username) && Boolean(password)) {
|
|
1244
|
+
dispath({ type: "inititatePasswordVerification" });
|
|
1245
|
+
const { status, data, message, responseType, access_token } = await veirfyUsernameandPassword(username, password);
|
|
1246
|
+
if (status === "0" && responseType === "S") {
|
|
1247
|
+
dispath({
|
|
1248
|
+
type: "passwordRotation",
|
|
1249
|
+
payload: {
|
|
1250
|
+
username: username,
|
|
1251
|
+
access_token: access_token?.access_token,
|
|
1252
|
+
token_type: access_token?.token_type,
|
|
1253
|
+
},
|
|
1254
|
+
});
|
|
1255
|
+
setOpenPwdReset(true);
|
|
1256
|
+
}
|
|
1257
|
+
else if (status === "0") {
|
|
1258
|
+
dispath({
|
|
1259
|
+
type: "passwordVerificationSuccessful",
|
|
1260
|
+
payload: {
|
|
1261
|
+
transactionID: data?.REQUEST_CD,
|
|
1262
|
+
username: username,
|
|
1263
|
+
access_token: access_token?.access_token,
|
|
1264
|
+
token_type: access_token?.token_type,
|
|
1265
|
+
authType: data?.AUTH_TYPE,
|
|
1266
|
+
auth_data: [
|
|
1267
|
+
{
|
|
1268
|
+
company_ID: data?.BASE_COMP_CD ?? "",
|
|
1269
|
+
branch_cd: data?.BASE_BRANCH_CD,
|
|
1270
|
+
},
|
|
1271
|
+
],
|
|
1272
|
+
otpValidFor: data?.OTP_VALID,
|
|
1273
|
+
},
|
|
1274
|
+
});
|
|
1275
|
+
}
|
|
1276
|
+
else {
|
|
1277
|
+
dispath({
|
|
1278
|
+
type: "passwordVerificationFailure",
|
|
1279
|
+
payload: { error: message, errorPassword: message },
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
else if (!Boolean(username) && !Boolean(password)) {
|
|
1284
|
+
dispath({
|
|
1285
|
+
type: "usernameandpasswordrequired",
|
|
1286
|
+
payload: {
|
|
1287
|
+
error: "UsernamenandPasswordisRequired",
|
|
1288
|
+
errorUsername: "UsernameisRequired",
|
|
1289
|
+
errorPassword: "PasswordisRequired",
|
|
1290
|
+
},
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
else if (!Boolean(username)) {
|
|
1294
|
+
dispath({
|
|
1295
|
+
type: "usernameVerificationFailure",
|
|
1296
|
+
payload: {
|
|
1297
|
+
error: "UsernameisRequired",
|
|
1298
|
+
errorUsername: "UsernameisRequired",
|
|
1299
|
+
},
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1302
|
+
else {
|
|
1303
|
+
dispath({
|
|
1304
|
+
type: "passwordVerificationFailure",
|
|
1305
|
+
payload: {
|
|
1306
|
+
error: "PasswordisRequired",
|
|
1307
|
+
errorPassword: "PasswordisRequired",
|
|
1308
|
+
},
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
};
|
|
1312
|
+
const VerifyOTP = async (OTPNumber) => {
|
|
1313
|
+
if (Boolean(OTPNumber) && OTPNumber.toString().length === 6) {
|
|
1314
|
+
dispath({ type: "inititateOTPVerification" });
|
|
1315
|
+
const { status, data, message } = await verifyOTP(loginState.transactionID,
|
|
1316
|
+
// loginState.app_transactionId,
|
|
1317
|
+
loginState.username, OTPNumber, loginState.access_token, loginState.token_type, loginState.authType);
|
|
1318
|
+
console.log("menuapierror", message);
|
|
1319
|
+
if (status === "0") {
|
|
1320
|
+
// try {
|
|
1321
|
+
// audio.play();
|
|
1322
|
+
// } catch (error) {
|
|
1323
|
+
// console.log(error);
|
|
1324
|
+
// }
|
|
1325
|
+
dispath({ type: "OTPVerificationComplate" });
|
|
1326
|
+
loginFn(data);
|
|
1327
|
+
}
|
|
1328
|
+
else if (status === "999") {
|
|
1329
|
+
dispath({
|
|
1330
|
+
type: "OTPVerificationFailed",
|
|
1331
|
+
payload: { error: message, otpmodelclose: true },
|
|
1332
|
+
});
|
|
1333
|
+
// enqueueSnackbar(message, { variant: "error" });
|
|
1334
|
+
}
|
|
1335
|
+
else {
|
|
1336
|
+
dispath({
|
|
1337
|
+
type: "OTPVerificationFailed",
|
|
1338
|
+
payload: { error: message, otpmodelclose: false },
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
else {
|
|
1343
|
+
dispath({
|
|
1344
|
+
type: "OTPVerificationFailed",
|
|
1345
|
+
payload: { error: "Please enter a 6 digit OTP number" },
|
|
1346
|
+
});
|
|
1347
|
+
}
|
|
1348
|
+
};
|
|
1349
|
+
const handlePasswordRotationClose = (flag) => {
|
|
1350
|
+
if (flag === "0") {
|
|
1351
|
+
dispath({
|
|
1352
|
+
type: "passwordRotationsuccess",
|
|
1353
|
+
payload: { otpmodelclose: true },
|
|
1354
|
+
});
|
|
1355
|
+
}
|
|
1356
|
+
setOpenPwdReset(false);
|
|
1357
|
+
};
|
|
1358
|
+
const changeUserName = (isError = false, errorMessage = "") => {
|
|
1359
|
+
dispath({
|
|
1360
|
+
type: "backToUsernameVerification",
|
|
1361
|
+
payload: {
|
|
1362
|
+
isError: isError,
|
|
1363
|
+
errorMessage: errorMessage,
|
|
1364
|
+
},
|
|
1365
|
+
});
|
|
1366
|
+
};
|
|
1367
|
+
const verifyFinger = async () => {
|
|
1368
|
+
try {
|
|
1369
|
+
dispath({ type: "inititateUserFingerScanner" });
|
|
1370
|
+
const fingerResponse = await capture();
|
|
1371
|
+
if (fingerResponse?.ErrorCode === "0") {
|
|
1372
|
+
dispath({ type: "inititateUserFingerVerification" });
|
|
1373
|
+
const promise = await matchFinger(loginState.auth_data, fingerResponse.IsoTemplate);
|
|
1374
|
+
if (promise.isError) {
|
|
1375
|
+
dispath({
|
|
1376
|
+
type: "biometricVerificationFailure",
|
|
1377
|
+
payload: {
|
|
1378
|
+
error: promise?.errorMessage ?? "Something went wrong.",
|
|
1379
|
+
},
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1382
|
+
else {
|
|
1383
|
+
const { status, data, message } = await verifyOTP(loginState.transactionID, loginState.username, String(promise?.sr_cd ?? "0"), loginState.access_token, loginState.token_type, loginState.authType, promise.status ? "Y" : "N");
|
|
1384
|
+
if (status === "0" && promise.status) {
|
|
1385
|
+
dispath({ type: "biometricVerificationSuccessful" });
|
|
1386
|
+
loginFn(data);
|
|
1387
|
+
}
|
|
1388
|
+
else if (status === "0" && !promise.status) {
|
|
1389
|
+
failureCount.current = failureCount.current + 1;
|
|
1390
|
+
dispath({
|
|
1391
|
+
type: "biometricVerificationFailure",
|
|
1392
|
+
payload: {
|
|
1393
|
+
error: "Finger Not Match.Please Try Again",
|
|
1394
|
+
},
|
|
1395
|
+
});
|
|
1396
|
+
if (failureCount.current >= 3)
|
|
1397
|
+
changeUserName(true, "Finger Not Match.Please Try Again");
|
|
1398
|
+
}
|
|
1399
|
+
else if (status === "99") {
|
|
1400
|
+
dispath({
|
|
1401
|
+
type: "biometricVerificationFailure",
|
|
1402
|
+
payload: {
|
|
1403
|
+
error: message ?? "Finger Not Match.Please Try Again",
|
|
1404
|
+
},
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
else if (status === "999") {
|
|
1408
|
+
dispath({
|
|
1409
|
+
type: "biometricVerificationFailure",
|
|
1410
|
+
payload: {
|
|
1411
|
+
error: message ?? "Finger Not Match.Please Try Again",
|
|
1412
|
+
},
|
|
1413
|
+
});
|
|
1414
|
+
changeUserName(true, message ?? "Finger Not Match.Please Try Again");
|
|
1415
|
+
}
|
|
1416
|
+
else {
|
|
1417
|
+
dispath({
|
|
1418
|
+
type: "biometricVerificationFailure",
|
|
1419
|
+
payload: {
|
|
1420
|
+
error: message ?? "Finger Not Match.Please Try Again",
|
|
1421
|
+
},
|
|
1422
|
+
});
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
else {
|
|
1427
|
+
dispath({
|
|
1428
|
+
type: "biometricVerificationFailure",
|
|
1429
|
+
payload: {
|
|
1430
|
+
error: fingerResponse?.ErrorMessage ?? t("Biometric.MFS100NotFound"),
|
|
1431
|
+
},
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
catch (e) {
|
|
1436
|
+
dispath({
|
|
1437
|
+
type: "biometricVerificationFailure",
|
|
1438
|
+
payload: {
|
|
1439
|
+
error: e?.message ?? t("Biometric.Unknownerroroccured"),
|
|
1440
|
+
},
|
|
1441
|
+
});
|
|
1442
|
+
}
|
|
1443
|
+
};
|
|
1444
|
+
return (jsx(Fragment$1, { children: loading ? (jsx(FullScreenLoader, {})) : (jsx(Fragment$1, { children: jsxs(Grid, { container: true, style: { height: "100vh", overflow: "hidden" }, children: [jsx(BankDetails, { bannerDetails: bannerDetails }), jsxs(Grid, { item: true, xs: 11, md: 6, lg: 6, sm: 6, children: [jsx(Grid, { container: true, direction: "row", justifyContent: "flex-end", alignItems: "center", padding: "25px", children: jsx(Tooltip, { describeChild: true, title: "Enfinity-CBS-UI-V1.0.17", children: jsx("img", { src: Boolean(dashboardLogoURL) ? dashboardLogoURL : "", alt: "Logo" }) }) }), openpwdreset ? (jsx(PasswordRotation, { classes: classes, ResetPassword: ResetPassword, open: openpwdreset, username: loginState.username, accessToken: loginState.access_token, tokenType: loginState.token_type, handleClose: handlePasswordRotationClose })) : (jsx(Fragment$1, { children: loginState.currentFlow === "username" ? (jsx(UsernamePasswordField, { classes: classes, loginState: loginState, verifyUsernamePassword: verifyUsernamePassword }, "username")) : (jsx(Fragment$1, { children: loginState.authType === "OTP" ? (jsx(OTPModel, { OTPResendRequest: OTPResendRequest, classes: classes, loginState: loginState, VerifyOTP: VerifyOTP, previousStep: changeUserName, OTPError: t(loginState?.OtpuserMessage ?? ""), setOTPError: (error) => {
|
|
1445
|
+
dispath({
|
|
1446
|
+
type: "OTPVerificationFailed",
|
|
1447
|
+
payload: { error: error },
|
|
1448
|
+
});
|
|
1449
|
+
}, open: true, handleClose: changeUserName, resendFlag: "LOGIN", setNewRequestID: (newRequestID) => {
|
|
1450
|
+
dispath({
|
|
1451
|
+
type: "OTPResendSuccess",
|
|
1452
|
+
payload: { transactionID: newRequestID },
|
|
1453
|
+
});
|
|
1454
|
+
otpResendRef.current = otpResendRef.current + 1;
|
|
1455
|
+
}, otpresendCount: otpResendRef.current }, "otp")) : loginState.authType === "TOTP" ? (jsxs(Fragment$1, { children: [" ", jsx(OTPModelForm, { OTPResendRequest: OTPResendRequest, classes: classes,
|
|
1456
|
+
// handleClose={() => {}}
|
|
1457
|
+
handleClose: changeUserName, loginState: loginState, VerifyOTP: VerifyOTP, OTPError: loginState?.OtpuserMessage ?? "", setOTPError: (error) => {
|
|
1458
|
+
dispath({
|
|
1459
|
+
type: "OTPVerificationFailed",
|
|
1460
|
+
payload: { error: error },
|
|
1461
|
+
});
|
|
1462
|
+
}, resendFlag: "LOGIN", setNewRequestID: (newRequestID) => {
|
|
1463
|
+
dispath({
|
|
1464
|
+
type: "OTPResendSuccess",
|
|
1465
|
+
payload: { transactionID: newRequestID },
|
|
1466
|
+
});
|
|
1467
|
+
otpResendRef.current = otpResendRef.current + 1;
|
|
1468
|
+
}, otpresendCount: otpResendRef.current }, "OTPForm")] })) : (jsx(VerifyFinger, { classes: classes, loginState: loginState, verifyFinger: verifyFinger, previousStep: changeUserName }, "biometric")) })) }))] })] }) })) }));
|
|
1469
|
+
};
|
|
1470
|
+
|
|
1471
|
+
export { AuthControllerWrapper };
|
|
1472
|
+
//# sourceMappingURL=index.js.map
|