remove password protection
This commit is contained in:
parent
c54d34f694
commit
838214cdf2
@ -1,29 +0,0 @@
|
|||||||
@import "@Themes/constants.scss";
|
|
||||||
|
|
||||||
.root {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
flex-direction: column;
|
|
||||||
height: 100%;
|
|
||||||
max-width: 530px;
|
|
||||||
margin: auto;
|
|
||||||
|
|
||||||
.title {
|
|
||||||
margin: 32px 0;
|
|
||||||
text-align: center;
|
|
||||||
|
|
||||||
@media (max-width: $screen-s) {
|
|
||||||
font-family: 48px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.forget-password {
|
|
||||||
margin-top: 32px;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
import Module from "@Front/Config/Module";
|
|
||||||
import { useRouter } from "next/router";
|
|
||||||
import { useState } from "react";
|
|
||||||
import Image from "next/image";
|
|
||||||
import classes from "./classes.module.scss";
|
|
||||||
import LandingImage from "./landing-connect.jpeg";
|
|
||||||
import DefaultDoubleSidePage from "@Front/Components/LayoutTemplates/DefaultDoubleSidePage";
|
|
||||||
import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography";
|
|
||||||
import CoffreIcon from "@Assets/Icons/coffre.svg";
|
|
||||||
import TextField from "@Front/Components/DesignSystem/Form/TextField";
|
|
||||||
import Button from "@Front/Components/DesignSystem/Button";
|
|
||||||
|
|
||||||
export default function Protect() {
|
|
||||||
const [password, setPassword] = useState("");
|
|
||||||
const router = useRouter();
|
|
||||||
const setPasswordFromInput = (event: React.ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => {
|
|
||||||
setPassword(event.target.value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const submitAuth = (e: React.FormEvent<HTMLFormElement>) => {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
if (password === "team-fullstack") {
|
|
||||||
console.log("ok");
|
|
||||||
setCookie("protect_staging", Date.now().toString());
|
|
||||||
router.push(Module.getInstance().get().modules.pages.Login.props.path);
|
|
||||||
} else {
|
|
||||||
console.log("pas ok");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const setCookie = (name: string, value: string) => {
|
|
||||||
if (!name || !value) throw new Error("Cookie name or value is empty");
|
|
||||||
const date = new Date();
|
|
||||||
|
|
||||||
// Set it expire in 7 days
|
|
||||||
date.setTime(date.getTime() + 7 * 24 * 60 * 60 * 1000);
|
|
||||||
|
|
||||||
// Set it
|
|
||||||
document.cookie = name + "=" + value + "; expires=" + date.toUTCString() + "; path=/";
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<DefaultDoubleSidePage title={"Login"} image={LandingImage}>
|
|
||||||
<div className={classes["root"]}>
|
|
||||||
<Image alt="coffre" src={CoffreIcon} />
|
|
||||||
<Typography typo={ITypo.H1}>
|
|
||||||
<div className={classes["title"]}>Le site est verrouillé</div>
|
|
||||||
</Typography>
|
|
||||||
<form onSubmit={submitAuth} className={classes["form"]}>
|
|
||||||
<TextField placeholder="Password" onChange={setPasswordFromInput} password />
|
|
||||||
<Button type="submit">Submit</Button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</DefaultDoubleSidePage>
|
|
||||||
);
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.5 MiB |
@ -4,9 +4,6 @@ import { NextResponse } from "next/server";
|
|||||||
import type { NextRequest } from "next/server";
|
import type { NextRequest } from "next/server";
|
||||||
|
|
||||||
export async function middleware(request: NextRequest) {
|
export async function middleware(request: NextRequest) {
|
||||||
const cookieStaging = request.cookies.get("protect_staging");
|
|
||||||
if (!cookieStaging) return NextResponse.redirect(new URL("/protect", request.url));
|
|
||||||
|
|
||||||
// Get the JWT from the cookies
|
// Get the JWT from the cookies
|
||||||
const cookies = request.cookies.get("leCoffreAccessToken");
|
const cookies = request.cookies.get("leCoffreAccessToken");
|
||||||
if (!cookies) return NextResponse.redirect(new URL("/login", request.url));
|
if (!cookies) return NextResponse.redirect(new URL("/login", request.url));
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
import Protect from "@Front/Components/Layouts/Protect";
|
|
||||||
|
|
||||||
export default function Route() {
|
|
||||||
return <Protect />;
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user