-
-
Notifications
You must be signed in to change notification settings - Fork 146
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
Adding PasswordLess login to sign in options #785
Merged
NiallJoeMaher
merged 17 commits into
codu-code:develop
from
JohnAllenTech:feat/612/add-passwordless-login
Mar 9, 2024
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
02c8e8d
chore: added passwordless login and altered signup page
ae40a01
Merge branch 'develop' into feat/612/add-passwordless-login
370c1d2
chore: fixed darkmode issue with error post passwordLess signin
2646d89
chore: updated dark/light mode for password input
e5e9344
chore: readding alpha flags
0e18498
Update app/(app)/auth/error/page.tsx
JohnAllenTech 25289b9
chore: added isMounted check
5623b4b
chore: addressing pr comments
930c40b
Merge branch 'develop' into feat/612/add-passwordless-login
JohnAllenTech 70a1151
Merge branch 'develop' into feat/612/add-passwordless-login
JohnAllenTech 0ffa731
chore: addressing PR comments
1c92eb6
Merge branch 'develop' into feat/612/add-passwordless-login
7b4f464
chore: now using sendEmail func to send passwordless emails and updat…
8d2bca5
chore: removing unused sample.env vars
d5fb822
Merge branch 'develop' into feat/612/add-passwordless-login
JohnAllenTech 570ecb1
Merge branch 'develop' into feat/612/add-passwordless-login
NiallJoeMaher 19379a8
removed newly introduced env variable
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"use client"; | ||
|
||
import type { NextPage } from "next"; | ||
import { useSearchParams } from "next/navigation"; | ||
import { PostAuthPage } from "../page"; | ||
|
||
const Page: NextPage = () => { | ||
const errorHeadings = { | ||
// sign in link already used or expired | ||
verification: { | ||
heading: "The sign in link is no longer valid", | ||
subHeading: "It may have been used already or it may have expired", | ||
}, | ||
// issue with email provider. SNS may be down or something similiar | ||
emailsignin: { | ||
heading: "Well this is embarrassing", | ||
subHeading: "Something unexpected happened, we will look into it", | ||
}, | ||
// if specific error param is not found give the generic | ||
unknown: { | ||
heading: "Oops... Not sure what happened there", | ||
subHeading: "Please try again later", | ||
}, | ||
}; | ||
// Checking does the error query param exist and if it doesnt replacing with unknown | ||
const error = (useSearchParams().get("error")?.toLowerCase() ?? | ||
"unknown") as keyof typeof errorHeadings; | ||
// Checking does the error query param has been covered in errorHeading if not falling back to unknown | ||
return PostAuthPage( | ||
errorHeadings[error] ? errorHeadings[error] : errorHeadings.unknown, | ||
); | ||
}; | ||
|
||
export default Page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
"use client"; | ||
|
||
import type { NextPage } from "next"; | ||
import Link from "next/link"; | ||
import Image from "next/image"; | ||
import { useTheme } from "next-themes"; | ||
import { THEME_MODES } from "@/components/Theme/ThemeToggle/ThemeToggle"; | ||
import { useEffect, useState } from "react"; | ||
|
||
export const PostAuthPage = (content: { | ||
heading: string; | ||
subHeading: string; | ||
}) => { | ||
const [mounted, setMounted] = useState(false); | ||
const { resolvedTheme } = useTheme(); | ||
|
||
// useEffect only happens on client not server | ||
useEffect(() => { | ||
setMounted(true); | ||
}, []); | ||
|
||
// if on server dont render. needed to prevent a hydration mismatch error | ||
if (!mounted) return null; | ||
|
||
return ( | ||
<main className="flex w-full flex-grow flex-col justify-center bg-neutral-100 px-4 py-20 dark:bg-black sm:px-6 lg:py-40"> | ||
<div className="flex flex-shrink-0 justify-center"> | ||
<Link href="/"> | ||
<span className="sr-only">Codú</span> | ||
<Image | ||
// Uses black codu logo if in light mode and white codu logo if in dark mode | ||
src={ | ||
resolvedTheme === THEME_MODES.LIGHT | ||
? "/images/codu-black.png" | ||
: "/images/codu.png" | ||
} | ||
alt="Codú logo" | ||
height={60} | ||
width={189} | ||
/> | ||
</Link> | ||
</div> | ||
<div className="py-16"> | ||
<div className="text-center"> | ||
<p className="bg-gradient-to-r from-orange-400 to-pink-600 bg-clip-text text-xl font-semibold uppercase leading-6 tracking-wide text-transparent"> | ||
{content.heading}{" "} | ||
</p> | ||
<h1 className="mt-2 text-4xl font-extrabold tracking-tight text-black dark:text-white sm:text-5xl"> | ||
{content.subHeading}{" "} | ||
</h1> | ||
<div className="mt-6"> | ||
<Link | ||
className="bg-gradient-to-r from-orange-400 to-pink-600 bg-clip-text text-base font-semibold tracking-wide text-transparent" | ||
href="/" | ||
> | ||
Return home<span aria-hidden="true"> →</span> | ||
</Link> | ||
</div> | ||
</div> | ||
</div> | ||
</main> | ||
); | ||
}; | ||
|
||
const Auth: NextPage = () => { | ||
return PostAuthPage({ | ||
heading: "Sign in email has been sent", | ||
subHeading: "See you soon 🚀", | ||
}); | ||
}; | ||
|
||
export default Auth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ import { MoonIcon, SunIcon } from "@heroicons/react/20/solid"; | |
import { useTheme } from "next-themes"; | ||
import { useEffect, useState } from "react"; | ||
|
||
const THEME_MODES = { | ||
export const THEME_MODES = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needed this exported so I could use it to determine the coco log that should be displayed. ie black or white |
||
DARK: "dark", | ||
LIGHT: "light", | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
GITHUB_ID= ### Replace with GitHub OAuth ID (https://github.com/settings/applications/new) | ||
GITHUB_SECRET= ### Replace with GitHub OAuth Secret (https://github.com/settings/applications/new) | ||
NEXTAUTH_URL=http://localhost:3000/api/auth | ||
DATABASE_URL=postgresql://postgres:[email protected]:5432/postgres | ||
DATABASE_URL=postgresql://postgres:[email protected]:5432/postgres |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The instructions for setting up Passwordless authentication locally are clear and helpful. Including a tutorial link for obtaining
ACCESS_KEY
andSECRET_KEY
values is a thoughtful addition. However, the note about the hardcoded AWS region ("eu-west-1") is crucial. It's recommended to make this configuration more flexible by allowing it to be set via environment variables, enhancing the application's adaptability to different deployment environments.Committable suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No because we dont set the AWS region in env variables. Dont want to add it as an env var as that would make this PR a breaking change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JohnAllenTech, understood. To ensure clarity for future contributors and users, it might be beneficial to document the hardcoded AWS region limitation in the README or relevant documentation. This can serve as a temporary measure until a more flexible solution is implemented. Appreciate your attention to maintaining the stability of the PR.