-
Notifications
You must be signed in to change notification settings - Fork 89
switch magic link to invite code #222
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
732782e
wip magic link codes
msukkari 01d1be9
pipe email to email provider properly
msukkari fcc1751
remove magic link data cookie after sign in
msukkari 426e4b3
clean up unused imports
msukkari 7279744
dont remove cookie before we use it
msukkari dbd7423
rm package-lock.json
msukkari f894e71
revert yarn files to v3 state
msukkari 228d3d5
switch email passing from cookie to search param
msukkari 4eb83e3
add comment for settings dropdown auth update
msukkari e95fd40
merge v3
msukkari 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,17 +1,99 @@ | ||
import { SourcebotLogo } from "@/app/components/sourcebotLogo"; | ||
"use client" | ||
|
||
import { InputOTPSeparator } from "@/components/ui/input-otp" | ||
import { InputOTPGroup } from "@/components/ui/input-otp" | ||
import { InputOTPSlot } from "@/components/ui/input-otp" | ||
import { InputOTP } from "@/components/ui/input-otp" | ||
import { Card, CardHeader, CardDescription, CardTitle, CardContent, CardFooter } from "@/components/ui/card" | ||
import { Button } from "@/components/ui/button" | ||
import { ArrowLeft } from "lucide-react" | ||
import { useRouter, useSearchParams } from "next/navigation" | ||
import { useCallback, useState } from "react" | ||
import VerificationFailed from "./verificationFailed" | ||
import { SourcebotLogo } from "@/app/components/sourcebotLogo" | ||
import useCaptureEvent from "@/hooks/useCaptureEvent" | ||
|
||
export default function VerifyPage() { | ||
const [value, setValue] = useState("") | ||
const searchParams = useSearchParams() | ||
const email = searchParams.get("email") | ||
const router = useRouter() | ||
const captureEvent = useCaptureEvent(); | ||
|
||
if (!email) { | ||
captureEvent("wa_login_verify_page_no_email", {}) | ||
return <VerificationFailed /> | ||
} | ||
|
||
const handleSubmit = useCallback(async () => { | ||
const url = new URL("/api/auth/callback/nodemailer", window.location.origin) | ||
url.searchParams.set("token", value) | ||
url.searchParams.set("email", email) | ||
router.push(url.toString()) | ||
}, [value]) | ||
|
||
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => { | ||
if (e.key === 'Enter' && value.length === 6) { | ||
handleSubmit() | ||
} | ||
} | ||
|
||
return ( | ||
<div className="flex flex-col items-center p-12 h-screen"> | ||
<SourcebotLogo | ||
className="mb-2 h-16" | ||
size="small" | ||
/> | ||
<h1 className="text-2xl font-bold mb-2">Verify your email</h1> | ||
<p className="text-sm text-muted-foreground"> | ||
{`We've sent a magic link to your email. Please check your inbox.`} | ||
</p> | ||
<div className="min-h-screen flex flex-col items-center justify-center p-4 bg-gradient-to-b from-background to-muted/30"> | ||
<div className="w-full max-w-md"> | ||
<div className="flex justify-center mb-6"> | ||
<SourcebotLogo className="h-16" size="large" /> | ||
</div> | ||
<Card className="w-full shadow-lg border-muted/40"> | ||
<CardHeader className="space-y-1"> | ||
<CardTitle className="text-2xl font-bold text-center">Verify your email</CardTitle> | ||
<CardDescription className="text-center"> | ||
Enter the 6-digit code we sent to <span className="font-semibold text-primary">{email}</span> | ||
</CardDescription> | ||
</CardHeader> | ||
|
||
<CardContent> | ||
<form onSubmit={(e) => { | ||
e.preventDefault() | ||
if (value.length === 6) { | ||
handleSubmit() | ||
} | ||
}} className="space-y-6"> | ||
<div className="flex justify-center py-4"> | ||
<InputOTP maxLength={6} value={value} onChange={setValue} onKeyDown={handleKeyDown} className="gap-2"> | ||
<InputOTPGroup> | ||
<InputOTPSlot index={0} className="rounded-md border-input" /> | ||
<InputOTPSlot index={1} className="rounded-md border-input" /> | ||
<InputOTPSlot index={2} className="rounded-md border-input" /> | ||
</InputOTPGroup> | ||
<InputOTPSeparator /> | ||
<InputOTPGroup> | ||
<InputOTPSlot index={3} className="rounded-md border-input" /> | ||
<InputOTPSlot index={4} className="rounded-md border-input" /> | ||
<InputOTPSlot index={5} className="rounded-md border-input" /> | ||
</InputOTPGroup> | ||
</InputOTP> | ||
</div> | ||
</form> | ||
</CardContent> | ||
|
||
<CardFooter className="flex flex-col space-y-4 pt-0"> | ||
<Button variant="ghost" className="w-full text-sm" size="sm" onClick={() => window.history.back()}> | ||
<ArrowLeft className="mr-2 h-4 w-4" /> | ||
Back to login | ||
</Button> | ||
</CardFooter> | ||
</Card> | ||
<div className="mt-8 text-center text-sm text-muted-foreground"> | ||
<p> | ||
Having trouble?{" "} | ||
<a href="mailto:team@sourcebot.dev" className="text-primary hover:underline"> | ||
Contact support | ||
</a> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
} | ||
|
This file contains hidden or 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,43 @@ | ||
"use client" | ||
|
||
import { Button } from "@/components/ui/button" | ||
import { AlertCircle } from "lucide-react" | ||
import { SourcebotLogo } from "@/app/components/sourcebotLogo" | ||
import { useRouter } from "next/navigation" | ||
|
||
export default function VerificationFailed() { | ||
const router = useRouter() | ||
|
||
return ( | ||
<div className="flex min-h-screen flex-col items-center justify-center bg-[#111318] text-white"> | ||
<div className="w-full max-w-md rounded-lg bg-[#1A1D24] p-8 shadow-lg"> | ||
<div className="mb-6 flex justify-center"> | ||
<SourcebotLogo /> | ||
</div> | ||
|
||
<div className="mb-6 text-center"> | ||
<div className="mb-4 flex justify-center"> | ||
<AlertCircle className="h-10 w-10 text-red-500" /> | ||
</div> | ||
<p className="mb-2 text-center text-lg font-medium">Login verification failed</p> | ||
<p className="text-center text-sm text-gray-400"> | ||
Something went wrong when trying to verify your login. Please try again. | ||
</p> | ||
</div> | ||
|
||
<Button onClick={() => router.push("/login")} className="w-full bg-purple-600 hover:bg-purple-700"> | ||
Return to login | ||
</Button> | ||
</div> | ||
|
||
<div className="mt-8 flex gap-6 text-sm text-gray-500"> | ||
<a href="https://www.sourcebot.dev" className="hover:text-gray-300"> | ||
About | ||
</a> | ||
<a href="mailto:team@sourcebot.dev" className="hover:text-gray-300"> | ||
Contact Us | ||
</a> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains hidden or 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 hidden or 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,71 @@ | ||
"use client" | ||
|
||
import * as React from "react" | ||
import { OTPInput, OTPInputContext } from "input-otp" | ||
import { Dot } from "lucide-react" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
const InputOTP = React.forwardRef< | ||
React.ElementRef<typeof OTPInput>, | ||
React.ComponentPropsWithoutRef<typeof OTPInput> | ||
>(({ className, containerClassName, ...props }, ref) => ( | ||
<OTPInput | ||
ref={ref} | ||
containerClassName={cn( | ||
"flex items-center gap-2 has-[:disabled]:opacity-50", | ||
containerClassName | ||
)} | ||
className={cn("disabled:cursor-not-allowed", className)} | ||
{...props} | ||
/> | ||
)) | ||
InputOTP.displayName = "InputOTP" | ||
|
||
const InputOTPGroup = React.forwardRef< | ||
React.ElementRef<"div">, | ||
React.ComponentPropsWithoutRef<"div"> | ||
>(({ className, ...props }, ref) => ( | ||
<div ref={ref} className={cn("flex items-center", className)} {...props} /> | ||
)) | ||
InputOTPGroup.displayName = "InputOTPGroup" | ||
|
||
const InputOTPSlot = React.forwardRef< | ||
React.ElementRef<"div">, | ||
React.ComponentPropsWithoutRef<"div"> & { index: number } | ||
>(({ index, className, ...props }, ref) => { | ||
const inputOTPContext = React.useContext(OTPInputContext) | ||
const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index] | ||
|
||
return ( | ||
<div | ||
ref={ref} | ||
className={cn( | ||
"relative flex h-10 w-10 items-center justify-center border-y border-r border-input text-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md", | ||
isActive && "z-10 ring-2 ring-ring ring-offset-background", | ||
className | ||
)} | ||
{...props} | ||
> | ||
{char} | ||
{hasFakeCaret && ( | ||
<div className="pointer-events-none absolute inset-0 flex items-center justify-center"> | ||
<div className="h-4 w-px animate-caret-blink bg-foreground duration-1000" /> | ||
</div> | ||
)} | ||
</div> | ||
) | ||
}) | ||
InputOTPSlot.displayName = "InputOTPSlot" | ||
|
||
const InputOTPSeparator = React.forwardRef< | ||
React.ElementRef<"div">, | ||
React.ComponentPropsWithoutRef<"div"> | ||
>(({ ...props }, ref) => ( | ||
<div ref={ref} role="separator" {...props}> | ||
<Dot /> | ||
</div> | ||
)) | ||
InputOTPSeparator.displayName = "InputOTPSeparator" | ||
|
||
export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator } |
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.
Uh oh!
There was an error while loading. Please reload this page.