-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new auth system and automated kite sessions (#23)
* wip: adding new login and signup routes * fix: adding session based auth apis * feat: changing redirection logic * fix: adding client login flow * feat: adding ui for adding kite integration * fix: adding ui and backend for integrations * fix: adding autosession login * fix: refactoring session code * feat: adding logic to load integration * fix: cleaning up env and adding header based auth * fix: fixing tick-workers logic * fix: minor deployment friendly changes * fix: adding pulumi deplyment * fix: fixing package lock issue * fix: fixing dockerfile for server
- Loading branch information
Showing
74 changed files
with
2,200 additions
and
568 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
SERVER_PRIVATE_URL=http://127.0.0.1:8000 | ||
CLIENT_URL=https://stonkninja.localhost |
This file was deleted.
Oops, something went wrong.
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,142 @@ | ||
"use client"; | ||
|
||
import { zodResolver } from "@hookform/resolvers/zod"; | ||
import { Loader2 } from "lucide-react"; | ||
import Link from "next/link"; | ||
import { useRouter } from "next/navigation"; | ||
import { useState } from "react"; | ||
import { useForm } from "react-hook-form"; | ||
import { z } from "zod"; | ||
|
||
import { Button } from "@/components/ui/button"; | ||
import { Form, FormControl, FormField, FormItem, FormMessage } from "@/components/ui/form"; | ||
import { Input } from "@/components/ui/input"; | ||
import { cn } from "@/lib/utils"; | ||
|
||
const loginFormSchema = z.object({ | ||
email: z.string().email(), | ||
password: z.string().min(8).max(32), | ||
}); | ||
|
||
interface UserLoginProps extends React.HTMLAttributes<HTMLDivElement> {} | ||
|
||
export default function UserLogin({ className, ...props }: UserLoginProps) { | ||
const form = useForm<z.infer<typeof loginFormSchema>>({ | ||
resolver: zodResolver(loginFormSchema), | ||
defaultValues: { | ||
email: "", | ||
password: "", | ||
}, | ||
}); | ||
const [isLoading, setIsLoading] = useState<boolean>(false); | ||
|
||
const router = useRouter(); | ||
|
||
async function onSubmit(values: z.infer<typeof loginFormSchema>) { | ||
setIsLoading(true); | ||
const res = await fetch("/api/auth/login", { | ||
method: "POST", | ||
body: JSON.stringify(values), | ||
headers: { "Content-Type": "application/json" }, | ||
}); | ||
setIsLoading(false); | ||
if (res.ok) { | ||
router.push("/private/dashboard"); | ||
} | ||
} | ||
|
||
return ( | ||
<div className="mb-8 mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[350px]"> | ||
<div className="mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[350px]"> | ||
<div className="flex flex-col space-y-2 text-center"> | ||
<h1 className="text-2xl font-semibold tracking-tight">Welcome back!</h1> | ||
<p className="text-sm text-muted-foreground"> | ||
Enter your email below to log into <strong>stonk.ninja</strong> | ||
</p> | ||
</div> | ||
</div> | ||
|
||
<div className={cn("grid gap-6", className)} {...props}> | ||
<Form {...form}> | ||
<form onSubmit={form.handleSubmit(onSubmit)}> | ||
<div className="grid gap-2"> | ||
<div className="grid gap-1"> | ||
<FormField | ||
control={form.control} | ||
name="email" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormControl> | ||
<Input | ||
id="email" | ||
placeholder="[email protected]" | ||
type="email" | ||
autoCapitalize="none" | ||
autoComplete="email" | ||
autoCorrect="off" | ||
disabled={isLoading} | ||
{...field} | ||
/> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
</div> | ||
<div className="grid gap-1"> | ||
<FormField | ||
control={form.control} | ||
name="password" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormControl> | ||
<Input | ||
id="password" | ||
placeholder="password" | ||
type="password" | ||
autoCapitalize="none" | ||
autoComplete="password" | ||
autoCorrect="off" | ||
disabled={isLoading} | ||
{...field} | ||
/> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
</div> | ||
<Button type="submit" disabled={isLoading}> | ||
{isLoading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />} | ||
Log In with Email | ||
</Button> | ||
</div> | ||
</form> | ||
</Form> | ||
{/* <div className="relative"> | ||
<div className="absolute inset-0 flex items-center"> | ||
<span className="w-full border-t" /> | ||
</div> | ||
<div className="relative flex justify-center text-xs uppercase"> | ||
<span className="bg-background px-2 text-muted-foreground">Or continue with</span> | ||
</div> | ||
</div> | ||
<Button variant="outline" type="button" disabled={isLoading}> | ||
{isLoading ? <Loader2 className="mr-2 h-4 w-4 animate-spin" /> : <GitHubLogoIcon className="mr-2 h-4 w-4" />}{" "} | ||
GitHub | ||
</Button> */} | ||
</div> | ||
<p className="px-4 text-center text-sm text-muted-foreground"> | ||
By clicking continue, you agree to our{" "} | ||
<Link href="/terms" className="underline underline-offset-4 hover:text-primary"> | ||
Terms of Service | ||
</Link>{" "} | ||
and{" "} | ||
<Link href="/privacy" className="underline underline-offset-4 hover:text-primary"> | ||
Privacy Policy | ||
</Link> | ||
. | ||
</p> | ||
</div> | ||
); | ||
} |
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
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.