-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
296 additions
and
32 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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { createClient } from "falkordb"; | ||
import CredentialsProvider from "next-auth/providers/credentials" | ||
import { AuthOptions } from "next-auth" | ||
|
||
const authOptions : AuthOptions = { | ||
providers: [ | ||
CredentialsProvider({ | ||
// The name to display on the sign in form (e.g. 'Sign in with...') | ||
name: 'Credentials', | ||
// The credentials is used to generate a suitable form on the sign in page. | ||
// You can specify whatever fields you are expecting to be submitted. | ||
// e.g. domain, username, password, 2FA token, etc. | ||
// You can pass any HTML attribute to the <input> tag through the object. | ||
credentials: { | ||
host: { label: "Host", type: "text", placeholder: "localhost" }, | ||
port: { label: "Port", type: "number", placeholder: "6379" }, | ||
username: { label: "Username", type: "text" }, | ||
password: { label: "Password", type: "password" } | ||
}, | ||
async authorize(credentials, req) { | ||
|
||
if (!credentials) { | ||
return null | ||
} | ||
|
||
try { | ||
let client = await createClient({ | ||
socket: { | ||
host: credentials.host ?? "localhost", | ||
port: credentials.port ? parseInt(credentials.port) : 6379, | ||
reconnectStrategy: false | ||
}, | ||
password: credentials.password ?? undefined, | ||
username: credentials.username ?? undefined | ||
}) | ||
.on('error', err => console.log('FalkorDB Client Error', err)) | ||
.connect(); | ||
|
||
let res : any = { | ||
host: credentials.host, | ||
port: credentials.port, | ||
password: credentials.password, | ||
username: credentials.username, | ||
} | ||
return res | ||
} catch (err) { | ||
console.log(err) | ||
return null; | ||
} | ||
} | ||
|
||
}) | ||
], | ||
callbacks: { | ||
async jwt({ token, user }) { | ||
if (user) { | ||
token.host = user.host; | ||
token.port = user.port; | ||
token.username = user.username; | ||
token.password = user.password; | ||
} | ||
|
||
return token; | ||
}, | ||
async session({ session, token, user }) { | ||
if (session.user) { | ||
session.user.host = token.host as string; | ||
session.user.port = parseInt(token.port as string); | ||
session.user.username = token.username as string; | ||
session.user.password = token.password as string; | ||
|
||
} | ||
return session; | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
export default authOptions |
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,7 @@ | ||
import NextAuth from "next-auth" | ||
import authOptions from "./options"; | ||
|
||
|
||
const handler = NextAuth(authOptions) | ||
|
||
export { handler as GET, handler as POST } |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,54 @@ | ||
'use client' | ||
|
||
import { CardTitle, CardDescription, CardHeader, CardContent, CardFooter, Card } from "@/components/ui/card" | ||
import { Label } from "@/components/ui/label" | ||
import { Input } from "@/components/ui/input" | ||
import { Button } from "@/components/ui/button" | ||
import { FormEvent } from "react" | ||
|
||
export default function Page() { | ||
function handleSubmit(event: FormEvent<HTMLFormElement>): void { | ||
event.preventDefault(); | ||
|
||
// Read the form data | ||
const form: any = event.target; | ||
const formData = new FormData(form); | ||
console.log(formData); | ||
} | ||
|
||
return ( | ||
<Card> | ||
<CardHeader> | ||
<form className="flex flex-col gap-2" onSubmit={handleSubmit}> | ||
<div className="p-4"> | ||
<CardTitle className="text-2xl font-semibold">Login FalkorDB server</CardTitle> | ||
<CardDescription className="text-gray-500"> | ||
Fill in the form below to login to your FalkorDB server. | ||
</CardDescription> | ||
</CardHeader> | ||
<CardContent className="space-y-4"> | ||
</div> | ||
<div className="space-y-4 flex flex-col p-4"> | ||
<div className="grid grid-cols-2 gap-4"> | ||
<div className="space-y-2"> | ||
<Label htmlFor="username">User Name</Label> | ||
<Input id="username" placeholder="Enter username if exits" type="text" /> | ||
<Label htmlFor="server">Server</Label> | ||
<Input id="server" placeholder="localhost" type="text" defaultValue="localhost" /> | ||
</div> | ||
<div className="space-y-2"> | ||
<Label htmlFor="password">Password</Label> | ||
<Input id="password" placeholder="Enter password if exits" type="password" /> | ||
<Label htmlFor="port">Port</Label> | ||
<Input id="port" placeholder="6379" type="number" min={1} max={65535} defaultValue={6379} /> | ||
</div> | ||
</div> | ||
<div className="grid grid-cols-2 gap-4"> | ||
<div className="space-y-2"> | ||
<Label htmlFor="server">Server</Label> | ||
<Input id="server" placeholder="Enter your email" type="text" /> | ||
<Label htmlFor="username">User Name</Label> | ||
<Input id="username" type="text" /> | ||
</div> | ||
<div className="space-y-2"> | ||
<Label htmlFor="port">Port</Label> | ||
<Input id="port" placeholder="Enter your email" type="number" /> | ||
<Label htmlFor="password">Password</Label> | ||
<Input id="password" type="password" /> | ||
</div> | ||
</div> | ||
<div className="space-y-2"> | ||
<Label htmlFor="url">URL</Label> | ||
<Input id="url" placeholder="Enter connection URL" type="url" /> | ||
</div> | ||
</CardContent> | ||
<CardFooter className="flex justify-end"> | ||
<Button>Login</Button> | ||
</CardFooter> | ||
</Card> | ||
</div> | ||
<div className="flex justify-end p-4"> | ||
<Button type="submit">Connect</Button> | ||
</div> | ||
</form> | ||
) | ||
} |
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,24 @@ | ||
"use client"; | ||
|
||
import Navbar from "@/components/custom/navbar"; | ||
import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@/components/ui/resizable"; | ||
import { SessionProvider } from "next-auth/react"; | ||
// import Navigation from "./components/navigation"; | ||
|
||
type Props = { | ||
children?: React.ReactNode; | ||
}; | ||
|
||
export const NextAuthProvider = ({ children }: Props) => { | ||
return ( | ||
<SessionProvider> | ||
<ResizablePanelGroup direction="horizontal" className='w-full h-full overflow-hidden'> | ||
<ResizablePanel defaultSize={10} maxSize={30} collapsible={true} minSize={10}> | ||
<Navbar /> | ||
</ResizablePanel> | ||
<ResizableHandle withHandle /> | ||
<ResizablePanel defaultSize={90}>{children}</ResizablePanel> | ||
</ResizablePanelGroup> | ||
</SessionProvider> | ||
) | ||
}; |
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.