diff --git a/context/Auth/index.ts b/context/Auth/index.ts
index 6a8071e6..287088ec 100644
--- a/context/Auth/index.ts
+++ b/context/Auth/index.ts
@@ -1,4 +1,3 @@
export { AuthProvider } from "./AuthContext";
export { useAuth } from "./AuthContext";
export { withAuth } from "./withAuth";
-export { withoutAuth } from "./withoutAuth";
diff --git a/context/Auth/withoutAuth.js b/context/Auth/withoutAuth.js
deleted file mode 100644
index dae9d26c..00000000
--- a/context/Auth/withoutAuth.js
+++ /dev/null
@@ -1,19 +0,0 @@
-import { faUserAstronaut } from "@fortawesome/free-solid-svg-icons";
-import { Router, useRouter } from "next/router";
-import { useAuth } from ".";
-
-export function withoutAuth(WrappedComponent) {
- // eslint-disable-next-line react/display-name
- return (props) => {
- const router = useRouter();
- const { user } = useAuth();
-
- if (user) {
- router.replace(
- (router.query.from && decodeURIComponent(router.query.from)) ?? "/"
- );
- return null;
- }
- return ;
- };
-}
diff --git a/generator/templates/layouts/layout.tsx.hbs b/generator/templates/layouts/layout.tsx.hbs
index 9a61fd4c..29b3e35c 100644
--- a/generator/templates/layouts/layout.tsx.hbs
+++ b/generator/templates/layouts/layout.tsx.hbs
@@ -1,6 +1,7 @@
-import {
-{{#if shouldAddAuth}}withAuth{{else}}withoutAuth{{/if}}
-} from "@context/Auth";
+
+{{#if shouldAddAuth}}
+import { withAuth } from "@context/Auth";
+{{/if}}
{{#if shouldAddComponents}}
import { Component } from "./components";
@@ -14,4 +15,4 @@ type
{{pascalCase name}}
); } export default
-{{#if shouldAddAuth}}withAuth{{else}}withoutAuth{{/if}}({{pascalCase name}});
\ No newline at end of file
+{{#if shouldAddAuth}}withAuth({{pascalCase name}}){{else}}{{pascalCase name}}{{/if}};
\ No newline at end of file
diff --git a/layout/Challenges/Challenges.tsx b/layout/Challenges/Challenges.tsx
index 5b98b804..5b56d86f 100644
--- a/layout/Challenges/Challenges.tsx
+++ b/layout/Challenges/Challenges.tsx
@@ -1,5 +1,3 @@
-import { withoutAuth } from "@context/Auth";
-
import Navbar from "@components/Navbar";
import Footer from "@components/Footer";
diff --git a/layout/FAQs/FAQs.tsx b/layout/FAQs/FAQs.tsx
index d841b3e2..ab375519 100644
--- a/layout/FAQs/FAQs.tsx
+++ b/layout/FAQs/FAQs.tsx
@@ -1,5 +1,3 @@
-import { withoutAuth } from "@context/Auth";
-
import Navbar from "@components/Navbar";
import Footer from "@components/Footer";
diff --git a/layout/ForgotPassword/ForgotPassword.tsx b/layout/ForgotPassword/ForgotPassword.tsx
index 571def29..a7d235dd 100644
--- a/layout/ForgotPassword/ForgotPassword.tsx
+++ b/layout/ForgotPassword/ForgotPassword.tsx
@@ -1,5 +1,3 @@
-import { withoutAuth } from "@context/Auth";
-
import { motion as Motion } from "framer-motion";
import Card from "@components/Card";
diff --git a/layout/Hackathon/Hackathon.tsx b/layout/Hackathon/Hackathon.tsx
index 0eb3e16f..ee7a8483 100644
--- a/layout/Hackathon/Hackathon.tsx
+++ b/layout/Hackathon/Hackathon.tsx
@@ -1,5 +1,3 @@
-import { withoutAuth } from "@context/Auth";
-
import { Hero, Awards, Regulations } from "./components";
import PeopleShowcase from "@components/PeopleShowcase";
diff --git a/layout/Home/Home.tsx b/layout/Home/Home.tsx
index af227eca..36fea787 100644
--- a/layout/Home/Home.tsx
+++ b/layout/Home/Home.tsx
@@ -1,5 +1,3 @@
-import { withoutAuth } from "@context/Auth";
-
import { Hero, Sponsors, Hackathon, Speakers, Partners } from "./components";
import Navbar from "@components/Navbar";
diff --git a/layout/Login/Login.tsx b/layout/Login/Login.tsx
index 964da312..052266bd 100644
--- a/layout/Login/Login.tsx
+++ b/layout/Login/Login.tsx
@@ -3,9 +3,10 @@
import { motion as Motion } from "framer-motion";
-import { withoutAuth } from "@context/Auth";
+import { useAuth } from "@context/Auth";
import Card from "@components/Card";
+import { Router, useRouter } from "next/router";
import Return from "@components/Return";
@@ -14,6 +15,17 @@ import Text from "@layout/moonstone/authentication/Text";
import { LoginForm } from "./components";
function Login() {
+ const router = useRouter();
+ const { user } = useAuth();
+
+ if (user) {
+ router.replace(
+ (router.query.from && decodeURIComponent(router.query.from as string)) ??
+ "/"
+ );
+ return null;
+ }
+
return (
@@ -46,4 +58,4 @@ function Login() {
);
}
-export default withoutAuth(Login);
+export default Login;
diff --git a/layout/ResetPassword/ResetPassword.tsx b/layout/ResetPassword/ResetPassword.tsx
index 057d9db9..856c89ae 100644
--- a/layout/ResetPassword/ResetPassword.tsx
+++ b/layout/ResetPassword/ResetPassword.tsx
@@ -1,5 +1,3 @@
-import { withoutAuth } from "@context/Auth";
-
import { motion as Motion } from "framer-motion";
import Card from "@components/Card";
diff --git a/layout/Schedule/Schedule.tsx b/layout/Schedule/Schedule.tsx
index f6fa39ff..8b63341c 100644
--- a/layout/Schedule/Schedule.tsx
+++ b/layout/Schedule/Schedule.tsx
@@ -1,5 +1,3 @@
-import { withoutAuth } from "@context/Auth";
-
import { Hero } from "./components";
import Navbar from "@components/Navbar";
diff --git a/layout/SignUp/SignUp.tsx b/layout/SignUp/SignUp.tsx
index bbc4b596..77f00974 100644
--- a/layout/SignUp/SignUp.tsx
+++ b/layout/SignUp/SignUp.tsx
@@ -1,5 +1,3 @@
-import { withoutAuth } from "@context/Auth";
-
import { motion as Motion } from "framer-motion";
import Card from "@components/Card";
diff --git a/layout/Speakers/Speakers.tsx b/layout/Speakers/Speakers.tsx
index f4684ebe..30532484 100644
--- a/layout/Speakers/Speakers.tsx
+++ b/layout/Speakers/Speakers.tsx
@@ -1,5 +1,4 @@
import { useRouter } from "next/router";
-import { withoutAuth } from "@context/Auth";
import { Hero, Schedule } from "./components";
diff --git a/layout/Team/Team.tsx b/layout/Team/Team.tsx
index 432415c1..b783122e 100644
--- a/layout/Team/Team.tsx
+++ b/layout/Team/Team.tsx
@@ -1,5 +1,3 @@
-import { withoutAuth } from "@context/Auth";
-
import { Hero, FindUs, Organization } from "./components";
import Navbar from "@components/Navbar";
diff --git a/pages/register/[uuid].js b/pages/register/[uuid].js
index bd77ba46..96621eb5 100644
--- a/pages/register/[uuid].js
+++ b/pages/register/[uuid].js
@@ -2,8 +2,6 @@ import { useState } from "react";
import { useRouter } from "next/router";
import { motion as Motion } from "framer-motion";
-import { withoutAuth, useAuth } from "@context/Auth";
-
import Button from "@components/Button";
import Card from "@components/Card";
import Return from "@components/Return";