Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SCRUM 193] User should not login again when they have already logged in #55

Merged
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
13 changes: 12 additions & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
"use client";
import Link from "next/link";
import Image from "next/image";
import { ArrowRightIcon } from "lucide-react";
import { useEffect, useState } from "react";

export default function Page() {
const [isAuthenticated, setIsAuthenticated] = useState(false);

useEffect(() => {
const access_token = localStorage.getItem("access_token");
const expiryTime = localStorage.getItem("token_expiry_time");
const isValid = access_token && expiryTime && new Date().getTime() <= parseInt(expiryTime);
setIsAuthenticated(isValid ? true : false);
}, []);

return (
<main className="flex min-h-screen flex-col p-6">
<div className="flex h-28 shrink-0 rounded-lg bg-sky-950 p-4 md:h-52 md:items-end">
Expand Down Expand Up @@ -37,7 +48,7 @@ export default function Page() {
</div>
<div className="flex flex-col gap-2 items-center md:flex-row md:items-start">
<Link
href="login"
href={isAuthenticated ? "/sendEmail" : "/login"}
className="flex items-center gap-2 rounded-lg bg-sky-950 px-6 py-3 text-sm font-medium text-white transition-colors hover:bg-sky-900 md:text-base"
>
<p className="animate-pulse">Let&apos;s Get Started</p>
Expand Down
Loading