- 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.
16 lines
326 B
TypeScript
16 lines
326 B
TypeScript
// middleware.ts
|
|
import { withAuth } from 'next-auth/middleware';
|
|
|
|
export default withAuth({
|
|
callbacks: {
|
|
authorized: ({ token }) => Boolean(token),
|
|
},
|
|
pages: {
|
|
signIn: '/',
|
|
},
|
|
});
|
|
|
|
export const config = {
|
|
matcher: ['/((?!auth|browser|telegram|unregistered|api|_next/static|_next/image|favicon.ico).*)'],
|
|
};
|