-
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.
remove GIGS_MANAGABLE_USER_EMAIL in favour of email login form; add fake login form storing email in a cookie; add auth protection: only allow going to /checkout and /backoffice if logged in
- Loading branch information
Showing
18 changed files
with
673 additions
and
26 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,3 +1,2 @@ | ||
GIGS_PROJECT= | ||
GIGS_API_KEY= | ||
GIGS_MANAGABLE_USER_EMAIL= |
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,13 @@ | ||
import { auth } from '@/lib/applicationMocks' | ||
import { LoginForm } from '@/components/LoginForm' | ||
|
||
type Props = { | ||
children: React.ReactNode | ||
} | ||
|
||
const Layout = async ({ children }: Props) => { | ||
const currentUser = auth.getUser() | ||
return currentUser.email ? <>{children}</> : <LoginForm /> | ||
} | ||
|
||
export default Layout |
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,13 @@ | ||
import { auth } from '@/lib/applicationMocks' | ||
import { LoginForm } from '@/components/LoginForm' | ||
|
||
type Props = { | ||
children: React.ReactNode | ||
} | ||
|
||
const Layout = async ({ children }: Props) => { | ||
const currentUser = auth.getUser() | ||
return currentUser.email ? <>{children}</> : <LoginForm /> | ||
} | ||
|
||
export default Layout |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use client' | ||
|
||
import { Button } from '@/components/ui/button' | ||
import { login } from '@/lib/actions' | ||
import { Input } from '@/components/ui/input' | ||
|
||
export const LoginForm = () => { | ||
return ( | ||
<div className="flex min-h-screen items-center justify-center"> | ||
<form role="form" action={login} className="w-96 space-y-6"> | ||
<div className="space-y-2"> | ||
<label htmlFor="email" className=""> | ||
Enter your mail | ||
</label> | ||
<Input | ||
name="email" | ||
type="email" | ||
id="email" | ||
required | ||
placeholder="example@gigs.com" | ||
autoFocus | ||
/> | ||
</div> | ||
<Button type="submit">Log In</Button> | ||
</form> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use client' | ||
|
||
import { logout } from '@/lib/actions' | ||
import { LogOut } from 'lucide-react' | ||
|
||
export const SideNavLogoutButton = () => { | ||
return ( | ||
<button | ||
className="mt-auto flex items-center gap-3 rounded-lg px-3 py-2 text-gray-900 transition-all hover:bg-gray-50 hover:text-gray-900 dark:text-gray-50 dark:hover:bg-gray-800 dark:hover:text-gray-50" | ||
onClick={() => logout()} | ||
> | ||
<LogOut className="h-4 w-4" /> | ||
Log out | ||
</button> | ||
) | ||
} |
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,43 @@ | ||
'use client' | ||
|
||
import { logout } from '@/lib/actions' | ||
import { UserCircle, LogOut } from 'lucide-react' | ||
|
||
import { | ||
Dropdown, | ||
DropdownContent, | ||
DropdownItem, | ||
DropdownPortal, | ||
DropdownTrigger, | ||
} from '@/components/ui/dropdown' | ||
|
||
type UserButtonProps = { | ||
user: string | undefined | ||
} | ||
|
||
export const UserButton = ({ user }: UserButtonProps) => { | ||
if (!user) { | ||
return null | ||
} | ||
|
||
return ( | ||
<Dropdown> | ||
<DropdownTrigger className="outline-none"> | ||
<div className="flex gap-2 text-gray-700 dark:text-gray-300"> | ||
<UserCircle /> | ||
{user} | ||
</div> | ||
</DropdownTrigger> | ||
<DropdownPortal> | ||
<DropdownContent align="end" sideOffset={5}> | ||
<DropdownItem onSelect={() => logout()} className="text-end"> | ||
<div className="flex gap-2"> | ||
<LogOut /> | ||
Log out | ||
</div> | ||
</DropdownItem> | ||
</DropdownContent> | ||
</DropdownPortal> | ||
</Dropdown> | ||
) | ||
} |
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,57 @@ | ||
'use client' | ||
|
||
import * as React from 'react' | ||
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu' | ||
|
||
import { cn } from '@/lib/utils' | ||
|
||
const Dropdown = DropdownMenuPrimitive.Root | ||
|
||
const DropdownTrigger = DropdownMenuPrimitive.Trigger | ||
|
||
const DropdownPortal = DropdownMenuPrimitive.Portal | ||
|
||
const DropdownContent = React.forwardRef< | ||
React.ElementRef<typeof DropdownMenuPrimitive.Content>, | ||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> | ||
>(({ className, children, ...props }, ref) => ( | ||
<DropdownMenuPrimitive.Content | ||
ref={ref} | ||
className={cn( | ||
'border border-neutral-200 bg-white px-4 py-2 shadow-lg duration-200 dark:border-neutral-800 dark:bg-neutral-950 sm:rounded-lg', | ||
'data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:slide-in-from-top-1/2', | ||
'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:slide-out-to-top-1/2', | ||
className, | ||
)} | ||
{...props} | ||
> | ||
{children} | ||
</DropdownMenuPrimitive.Content> | ||
)) | ||
DropdownContent.displayName = DropdownMenuPrimitive.Content.displayName | ||
|
||
const DropdownItem = React.forwardRef< | ||
React.ElementRef<typeof DropdownMenuPrimitive.Item>, | ||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> | ||
>(({ className, children, ...props }, ref) => ( | ||
<DropdownMenuPrimitive.Item | ||
ref={ref} | ||
className={cn( | ||
'cursor-default select-none rounded-md px-2 py-2 text-sm outline-none', | ||
'text-gray-700 focus:bg-gray-50 dark:text-gray-300 dark:focus:bg-gray-900', | ||
className, | ||
)} | ||
{...props} | ||
> | ||
{children} | ||
</DropdownMenuPrimitive.Item> | ||
)) | ||
DropdownItem.displayName = DropdownMenuPrimitive.Item.displayName | ||
|
||
export { | ||
Dropdown, | ||
DropdownTrigger, | ||
DropdownContent, | ||
DropdownPortal, | ||
DropdownItem, | ||
} |
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,26 @@ | ||
import * as React from 'react' | ||
|
||
import { cn } from '@/lib/utils' | ||
|
||
export const Input = React.forwardRef< | ||
HTMLInputElement, | ||
React.InputHTMLAttributes<HTMLInputElement> | ||
>((props, ref) => { | ||
const { className, ...inputProps } = props | ||
|
||
return ( | ||
<input | ||
ref={ref} | ||
className={cn( | ||
'block w-full rounded-lg border text-left text-base transition', | ||
'font-medium placeholder:text-gray-500 focus:border-gray-600 focus:ring-1 focus:ring-gray-600', | ||
'h-[52px] px-2 py-4 outline-none', | ||
'border-gray-400 bg-white text-gray-800', | ||
'[&:not(:placeholder-shown)]:invalid:border-rose-400 [&:not(:placeholder-shown)]:invalid:focus:border-rose-600' + | ||
'[&:not(:placeholder-shown)]:invalid:ring-rose-600 [&:not(:placeholder-shown)]:invalid:focus:ring-rose-600', | ||
className, | ||
)} | ||
{...inputProps} | ||
/> | ||
) | ||
}) |
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
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.