Skip to content

Commit

Permalink
Remove withoutAuth
Browse files Browse the repository at this point in the history
  • Loading branch information
tiago-bacelar committed Nov 29, 2023
1 parent e2247dc commit 30f125c
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 47 deletions.
1 change: 0 additions & 1 deletion context/Auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { AuthProvider } from "./AuthContext";
export { useAuth } from "./AuthContext";
export { withAuth } from "./withAuth";
export { withoutAuth } from "./withoutAuth";
19 changes: 0 additions & 19 deletions context/Auth/withoutAuth.js

This file was deleted.

9 changes: 5 additions & 4 deletions generator/templates/layouts/layout.tsx.hbs
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -14,4 +15,4 @@ type
<h1>{{pascalCase name}}</h1>
</div>
); } export default
{{#if shouldAddAuth}}withAuth{{else}}withoutAuth{{/if}}({{pascalCase name}});
{{#if shouldAddAuth}}withAuth({{pascalCase name}}){{else}}{{pascalCase name}}{{/if}};
2 changes: 0 additions & 2 deletions layout/Challenges/Challenges.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { withoutAuth } from "@context/Auth";

import Navbar from "@components/Navbar";
import Footer from "@components/Footer";

Expand Down
2 changes: 0 additions & 2 deletions layout/FAQs/FAQs.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { withoutAuth } from "@context/Auth";

import Navbar from "@components/Navbar";
import Footer from "@components/Footer";

Expand Down
2 changes: 0 additions & 2 deletions layout/ForgotPassword/ForgotPassword.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { withoutAuth } from "@context/Auth";

import { motion as Motion } from "framer-motion";

import Card from "@components/Card";
Expand Down
2 changes: 0 additions & 2 deletions layout/Hackathon/Hackathon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { withoutAuth } from "@context/Auth";

import { Hero, Awards, Regulations } from "./components";

import PeopleShowcase from "@components/PeopleShowcase";
Expand Down
2 changes: 0 additions & 2 deletions layout/Home/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { withoutAuth } from "@context/Auth";

import { Hero, Sponsors, Hackathon, Speakers, Partners } from "./components";

import Navbar from "@components/Navbar";
Expand Down
16 changes: 14 additions & 2 deletions layout/Login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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 (
<div className="min-h-screen overflow-hidden bg-secondary">
<Return componentStyle="sm:ml-20 mt-20 sm:mt-20" />
Expand Down Expand Up @@ -46,4 +58,4 @@ function Login() {
);
}

export default withoutAuth(Login);
export default Login;
2 changes: 0 additions & 2 deletions layout/ResetPassword/ResetPassword.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { withoutAuth } from "@context/Auth";

import { motion as Motion } from "framer-motion";

import Card from "@components/Card";
Expand Down
2 changes: 0 additions & 2 deletions layout/Schedule/Schedule.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { withoutAuth } from "@context/Auth";

import { Hero } from "./components";

import Navbar from "@components/Navbar";
Expand Down
2 changes: 0 additions & 2 deletions layout/SignUp/SignUp.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { withoutAuth } from "@context/Auth";

import { motion as Motion } from "framer-motion";

import Card from "@components/Card";
Expand Down
1 change: 0 additions & 1 deletion layout/Speakers/Speakers.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useRouter } from "next/router";
import { withoutAuth } from "@context/Auth";

import { Hero, Schedule } from "./components";

Expand Down
2 changes: 0 additions & 2 deletions layout/Team/Team.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { withoutAuth } from "@context/Auth";

import { Hero, FindUs, Organization } from "./components";

import Navbar from "@components/Navbar";
Expand Down
2 changes: 0 additions & 2 deletions pages/register/[uuid].js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 30f125c

Please sign in to comment.