Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_MAIN_URL=http://localhost:3000
19 changes: 19 additions & 0 deletions middleware.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export async function checkAuth(req, res, next) {
// Your authentication logic here
const verify = req.cookies.quickSilverAuth;

console.log("From middleware!");

if (!verify && req.url.includes("/dashboard")) {
res.redirect(302, `http://localhost:3000`);
return;
}

if (verify && (req.url.includes("/sign-up") || req.url === "/")) {
res.redirect(302, `${process.env.NEXT_PUBLIC_MAIN_URL}/dashboard`);
return;
}

// If authentication is successful, call the next function
next();
}
14 changes: 12 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
}
images: {
remotePatterns: [
{
protocol: "https",
hostname: "assets.example.com",
port: "",
pathname: "/account123/**",
},
],
},
};

module.exports = nextConfig
module.exports = nextConfig;
112 changes: 111 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
"lint": "next lint"
},
"dependencies": {
"@reduxjs/toolkit": "^2.1.0",
"js-cookie": "^3.0.5",
"next": "14.0.4",
"react": "^18",
"react-dom": "^18",
"react-icons": "^5.0.1",
"recharts": "^2.10.4"
"react-redux": "^9.1.0",
"recharts": "^2.10.4",
"sweetalert2": "^11.10.4"
},
"devDependencies": {
"autoprefixer": "^10.4.16",
Expand Down
57 changes: 49 additions & 8 deletions src/Components/Auth/Forgot.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,46 @@

import Link from "next/link";
import AuthLayout from "../../Layout/AuthLayout";
import { useRouter } from "next/router";
import Swal from "sweetalert2";

const Forgot = ({ sendResetPasswordLink, isLoading }) => {
const { push } = useRouter();
const handleSubmit = async (e) => {
e.preventDefault();

const Forgot = () => {
const email = e.target.email.value;
try {
const res = await sendResetPasswordLink({ email });
if (res?.error?.error) {
Swal.fire({
icon: "error",
title: "Oops...",
text: `${res?.error?.error}`,
});
}
if (res?.error?.data?.message) {
Swal.fire({
icon: "error",
title: "Oops...",
text: `${res?.error?.data?.message}`,
});
}
if (res?.data?.success) {
push("/");
Swal.fire({
icon: "success",
title: "Successful!",
text: `${res?.data?.message}`,
});
}
} catch (error) {
Swal.fire({
icon: "error",
title: "Oops...",
text: `${error?.message}`,
});
}
};
return (
<AuthLayout>
<div className="signIn">
Expand All @@ -12,7 +50,7 @@ const Forgot = () => {
Sign Up
</Link>
</div>
<form>
<form onSubmit={handleSubmit}>
<h2 className="text-[32px]">Forgot Password </h2>
<p className="fs-6 subtitle">
Enter your email and a password reset will be sent to you
Expand All @@ -22,18 +60,21 @@ const Forgot = () => {
<span>*</span> Email Address
</label>
<input
className="p-5 h-[unset]"
className="p-5 h-[unset]"
type="email"
name="email"
id="email"
placeholder="Enter your email address"
required
/>
</div>
<p className="err_sms mb-5">Invalid Email Address</p>
{/* <p className="err_sms mb-5">Invalid Email Address</p> */}

<Link href="/reset-password">
<button className="signIn_btn text-[20px]">Reset Password</button>
</Link>
{/* <Link href="/reset-password"> */}
<button className="signIn_btn text-[20px]" disabled={isLoading}>
{isLoading ? "Loading..." : "Reset Password"}
</button>
{/* </Link> */}
</form>
<div></div>
</div>
Expand Down
Loading