- Updated the authentication logic in both Auth and useAuth functions to redirect unregistered users to the '/unregistered' page. - Enhanced error handling in the authOptions to check for user registration status using the Telegram ID. - Improved the matcher configuration in middleware to exclude the '/unregistered' route from authentication checks.
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
'use client';
|
||
|
||
import { Button } from '@repo/ui/components/ui/button';
|
||
import { Bot, ExternalLink } from 'lucide-react';
|
||
import Link from 'next/link';
|
||
import { signOut } from 'next-auth/react';
|
||
|
||
type UnregisteredClientProps = {
|
||
readonly botUrl: string;
|
||
};
|
||
|
||
export function UnregisteredClient({ botUrl }: UnregisteredClientProps) {
|
||
const handleSignOut = () => {
|
||
signOut({ callbackUrl: '/' });
|
||
};
|
||
const handleRefresh = () => {
|
||
window.location.reload();
|
||
};
|
||
|
||
return (
|
||
<div className="flex flex-col gap-2">
|
||
<Button asChild className="w-full">
|
||
<Link href={botUrl} rel="noopener noreferrer" target="_blank">
|
||
<Bot className="mr-2 size-4" />
|
||
Перейти к боту
|
||
<ExternalLink className="ml-2 size-4" />
|
||
</Link>
|
||
</Button>
|
||
<Button className="w-full" onClick={handleRefresh} variant="outline">
|
||
Обновить страницу
|
||
</Button>
|
||
<Button className="w-full" onClick={handleSignOut} variant="outline">
|
||
Выйти из аккаунта
|
||
</Button>
|
||
</div>
|
||
);
|
||
}
|