Full authentication in front
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
|
||||
export const Login = () => {
|
||||
async function handleLogin(e: any) {
|
||||
e.preventDefault()
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={ handleLogin }>
|
||||
<input type={ "text" } name={ "email" } />
|
||||
<input type={ "password" } name={ "password" } />
|
||||
<input type={ "submit" } />
|
||||
</form>
|
||||
)
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
import {Navigate, Outlet} from "react-router";
|
||||
|
||||
type AuthUser = { id: string; name: string };
|
||||
|
||||
type ProtectedRouteProps = {
|
||||
user: AuthUser | null;
|
||||
redirectPath?: string;
|
||||
};
|
||||
|
||||
export const ProtectedRoute = ({ user, redirectPath = "/" }: ProtectedRouteProps) => {
|
||||
if (!user) {
|
||||
return <Navigate to={redirectPath} replace />;
|
||||
}
|
||||
|
||||
return <Outlet />;
|
||||
};
|
||||
@@ -1,15 +0,0 @@
|
||||
|
||||
export const Register = () => {
|
||||
async function handleRegister(e: any) {
|
||||
e.preventDefault()
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={ handleRegister }>
|
||||
<input type={ "text" } name={ "email" } />
|
||||
<input type={ "password" } name={ "password" }/>
|
||||
<input type={ "password" } name={ "confirm_password" }/>
|
||||
<input type={ "submit" } />
|
||||
</form>
|
||||
)
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
|
||||
|
||||
export const EntityList = () => {
|
||||
return (
|
||||
<h1>List des entity: Yoyoyo</h1>
|
||||
)
|
||||
}
|
||||
5
gui/rpk-gui/src/pages/forgotPassword/index.tsx
Normal file
5
gui/rpk-gui/src/pages/forgotPassword/index.tsx
Normal file
@@ -0,0 +1,5 @@
|
||||
import { AuthPage } from "@refinedev/mui";
|
||||
|
||||
export const ForgotPassword = () => {
|
||||
return <AuthPage type="forgotPassword" />;
|
||||
};
|
||||
32
gui/rpk-gui/src/pages/login/index.tsx
Normal file
32
gui/rpk-gui/src/pages/login/index.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { AuthPage } from "@refinedev/mui";
|
||||
|
||||
import GoogleIcon from "@mui/icons-material/Google";
|
||||
import DiscordIcon from "../../components/DiscordIcon";
|
||||
import { useSearchParams, Navigate } from "react-router";
|
||||
|
||||
export const Login = () => {
|
||||
const [searchParams] = useSearchParams();
|
||||
if (searchParams.get("oauth") == "success") {
|
||||
const redirect_to = localStorage.getItem("redirect_after_login")
|
||||
if (redirect_to) {
|
||||
return (<Navigate replace to={ redirect_to } />);
|
||||
}
|
||||
}
|
||||
return (
|
||||
<AuthPage
|
||||
type="login"
|
||||
formProps={{ defaultValues: { email: "test@test.te", password: "test" }, }}
|
||||
providers={[{
|
||||
name: "google",
|
||||
label: "Sign in with Google",
|
||||
icon: (<GoogleIcon style={{ fontSize: 24, }} />),
|
||||
},
|
||||
{
|
||||
name: "discord",
|
||||
label: "Sign in with Discord",
|
||||
icon: (<DiscordIcon style={{ fontSize: 24, }} />),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
};
|
||||
5
gui/rpk-gui/src/pages/register/index.tsx
Normal file
5
gui/rpk-gui/src/pages/register/index.tsx
Normal file
@@ -0,0 +1,5 @@
|
||||
import { AuthPage } from "@refinedev/mui";
|
||||
|
||||
export const Register = () => {
|
||||
return <AuthPage type="register" />;
|
||||
};
|
||||
9
gui/rpk-gui/src/pages/updatePassword/index.tsx
Normal file
9
gui/rpk-gui/src/pages/updatePassword/index.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import { AuthPage } from "@refinedev/mui";
|
||||
import type {RegisterFormTypes} from "@refinedev/core";
|
||||
|
||||
import { useParams } from "react-router"
|
||||
|
||||
export const UpdatePassword = () => {
|
||||
|
||||
return <AuthPage type="updatePassword"/>;
|
||||
};
|
||||
Reference in New Issue
Block a user