Skip to content
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

fix: restrict authentication of users #5

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/app/api/auth/[...nextauth]/auth-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ export const authOptions: NextAuthOptions = {

return session
},
signIn({ user }) {
const availableEmails = ['[email protected]']

if (availableEmails.includes(user.email)) {
return true
}

return false
},
},
session: {
strategy: 'jwt',
Expand Down
30 changes: 29 additions & 1 deletion src/app/auth/error/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
import { Button } from '@/components/ui/button'
import { Card, CardContent } from '@/components/ui/card'
import { Settings } from 'lucide-react'
import Link from 'next/link'

export default function SignInError() {
return <h1>Error</h1>
return (
<div className="wrapper">
<div className="flex items-center justify-center page-container">
<Card>
<CardContent className="mt-6 flex flex-col items-center justify-center gap-6">
<Settings size={24} className="animate-spin" />

<div>
<span className="block text-2xl font-semibold">
A plataforma ainda está em construção
</span>
<span className="block text-center text-muted-foreground">
O acesso é limite somente a alguns usuário
</span>
</div>

<Button asChild>
<Link href="/">Voltar para a página inicial</Link>
</Button>
</CardContent>
</Card>
</div>
</div>
)
}