From e6ce134fdc01e95bf7f359425aedc1afc2683063 Mon Sep 17 00:00:00 2001 From: Mohamed Ghayyad Date: Wed, 8 Nov 2023 14:18:05 +0000 Subject: [PATCH] Add Test Password Authenticator user interface. --- src/components/Nav.jsx | 2 +- src/components/passwordauth.jsx | 132 ++++++++++++++++++++++++++++++++ src/index.js | 5 ++ 3 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 src/components/passwordauth.jsx diff --git a/src/components/Nav.jsx b/src/components/Nav.jsx index c9bc9ea8a..dd15dcb68 100644 --- a/src/components/Nav.jsx +++ b/src/components/Nav.jsx @@ -35,7 +35,7 @@ function Navlinks(){ icon={} childrenOffset={28} > - } /> + } href="/pauthenticate"/> } /> } /> } /> diff --git a/src/components/passwordauth.jsx b/src/components/passwordauth.jsx new file mode 100644 index 000000000..01f66d102 --- /dev/null +++ b/src/components/passwordauth.jsx @@ -0,0 +1,132 @@ +import { Text,TextInput, Button, Stepper, Box, Group,Grid, Chip, Badge, Center,PasswordInput, JsonInput,Code} from '@mantine/core'; +import axios from 'axios'; +import { notifications } from '@mantine/notifications'; +import { IconCheck,IconAlertCircle, IconFaceIdError, IconEarOff, IconFaceId,IconLock, IconUserCircle, IconAt } from '@tabler/icons-react'; +import { useForm } from '@mantine/form'; +import { useState } from 'react'; + +function PasswordAuth(){ + const [active, setActive] = useState(0); + let email = ''; + let Password = ''; + const clientId = ''; + const clientSecret = ''; + let policy = ''; + const form = useForm({ + initialValues: { email: '', password: '',policy:'AT_RESPWD',channel:'CH_DIRECT',clientId:'',clientSecret:''}, + + // functions will be used to validate values at corresponding key + validate: (values) => { + if (active === 1) { + return { + email: + values.email.trim().length < 6 + ? 'Username must include at least 6 characters' + : null, + password: + values.password.length < 6 ? 'Password must include at least 6 characters' : null, + }; + } + + if (active === 0) { + return { + clientId: values.clientId.trim().length < 2 ? 'Name must include at least 2 characters' : null, + clientSecret: values.clientSecret.trim().length < 2 ? 'Client Secret at least 2 characters' : null, + }; + } + + return {}; + }, + }); + const nextStep = () => + setActive((current) => { + if (form.validate().hasErrors) { + return current; + } + return current < 3 ? current + 1 : current; + }); + + const prevStep = () => setActive((current) => (current > 0 ? current - 1 : current)); + + return( + <> + + + + ({ + backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[6] : theme.colors.gray[0], + padding: theme.spacing.xl, + borderRadius: theme.radius.md, + cursor: 'pointer', + + '&:hover': { + backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[1], + }, + })} + > +

Test Password Authenticator.

+ + + + + + +
+ Disconnected +
+ + + + + +
+ Connected +
+ + Completed! Form values: + + {JSON.stringify(form.values, null, 2)} + + +
+ +
+
+ +
+ + {active !== 0 && ( + + )} + {active !== 3 && } + + + + + + +
+
+ +
+ + ); + +} + +export default PasswordAuth; \ No newline at end of file diff --git a/src/index.js b/src/index.js index 61f66113e..ad1c10c42 100644 --- a/src/index.js +++ b/src/index.js @@ -5,6 +5,7 @@ import RegisterUser from "./components/RegisterUser.js"; import * as ReactDOM from "react-dom/client"; import ViewUsers from "./components/ViewUsers"; import CreatePasswordAuth from "./components/CreatePasswordAuth"; +import PasswordAuth from "./components/passwordauth.jsx"; import { createBrowserRouter, RouterProvider, @@ -34,6 +35,10 @@ import { { path: "/createPasswordAuthenticator", element: , + }, + { + path: "pauthenticate", + element : , } ], },