Fix typescript errors
This commit is contained in:
parent
171914941e
commit
4880e0d94e
1 changed files with 8 additions and 8 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
import { NextAuthConfig } from "next-auth";
|
import { NextAuthConfig } from 'next-auth';
|
||||||
|
|
||||||
export const authConfig = {
|
export const authConfig = {
|
||||||
pages: {
|
pages: {
|
||||||
signIn: "/login",
|
signIn: '/login',
|
||||||
newUser: "/",
|
newUser: '/',
|
||||||
},
|
},
|
||||||
providers: [
|
providers: [
|
||||||
// added later in auth.ts since it requires bcrypt which is only compatible with Node.js
|
// added later in auth.ts since it requires bcrypt which is only compatible with Node.js
|
||||||
|
|
@ -12,12 +12,12 @@ export const authConfig = {
|
||||||
callbacks: {
|
callbacks: {
|
||||||
authorized({ auth, request: { nextUrl } }) {
|
authorized({ auth, request: { nextUrl } }) {
|
||||||
let isLoggedIn = !!auth?.user;
|
let isLoggedIn = !!auth?.user;
|
||||||
let isOnChat = nextUrl.pathname.startsWith("/");
|
let isOnChat = nextUrl.pathname.startsWith('/');
|
||||||
let isOnRegister = nextUrl.pathname.startsWith("/register");
|
let isOnRegister = nextUrl.pathname.startsWith('/register');
|
||||||
let isOnLogin = nextUrl.pathname.startsWith("/login");
|
let isOnLogin = nextUrl.pathname.startsWith('/login');
|
||||||
|
|
||||||
if (isLoggedIn && (isOnLogin || isOnRegister)) {
|
if (isLoggedIn && (isOnLogin || isOnRegister)) {
|
||||||
return Response.redirect(new URL("/", nextUrl));
|
return Response.redirect(new URL('/', nextUrl as unknown as URL));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOnRegister || isOnLogin) {
|
if (isOnRegister || isOnLogin) {
|
||||||
|
|
@ -30,7 +30,7 @@ export const authConfig = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLoggedIn) {
|
if (isLoggedIn) {
|
||||||
return Response.redirect(new URL("/", nextUrl));
|
return Response.redirect(new URL('/', nextUrl as unknown as URL));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue