Skip to content

Commit

Permalink
Debug: try to fix login bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauritzskog committed Sep 21, 2024
1 parent 9d60cea commit dbdf5de
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions frontend/src/app/auth/new-password/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { NewPasswordForm } from "@/components/auth/new-password-form";
import { Suspense } from "react";

export const revalidate = 0;

const NewPasswordPage = () => {
return (
<div className="h-full">
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/app/auth/new-verification/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { NewVerificationForm } from "@/components/auth/new-verification-form";
import { Suspense } from "react";

export const revalidate = 0;

const NewVerificationPage = () => {
return (
<div className="h-full">
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/app/auth/register/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { RegisterForm } from "@/components/auth/register-form";

export const revalidate = 0;

const RegisterPage = () => {
return (
<div className="w-full h-full flex justify-center items-center ">
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/app/auth/reset/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { ResetForm } from "@/components/auth/reset-form";

export const revalidate = 0;

const ResetPage = () => {
return <ResetForm />;
};
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const publicRoutes = [
"/naeringsliv",
"/auth/new-verification",
"/api/styret",
"/api/komite",
"/api/komite/logo",
"/api/arrangementer",
"/api/samarbeidspartner",
Expand All @@ -31,9 +32,7 @@ export const authRoutes = [
"/auth/new-password",
];

export const adminRoutes = [
"/admin",
]
export const adminRoutes = ["/admin"];

/**
* The prefix for API authentication routes
Expand Down
9 changes: 2 additions & 7 deletions frontend/src/utils/new-verification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
let verificationInProgress = false;

export const newVerification = async (token: string) => {
if (verificationInProgress) {
console.log("Verification is already in progress.");
return;
}

verificationInProgress = true;
console.log("Starting verification process for token:", token);

Expand Down Expand Up @@ -41,11 +36,11 @@ export const newVerification = async (token: string) => {

if (existingUser.emailVerified) {
console.log("Email already verified");
window.location.href = "/auth/login";
return { error: "Email allerede registrert!" };
}

try {
// Update the user to mark the email as verified
await db.user.update({
where: { id: existingUser.id },
data: {
Expand All @@ -54,7 +49,7 @@ export const newVerification = async (token: string) => {
},
});

await delay(3000); // 30,000 milliseconds = 30 seconds
await delay(3000);

return { success: "Email verified and token deleted!" };
} catch (error) {
Expand Down

0 comments on commit dbdf5de

Please sign in to comment.