Open solomonshalom opened 2 days ago
Hey @solomonshalom, thanks for reaching out!
If you want to allow unauthenticated users to use the chatbot, you will have to comment out some of the checks in auth.config.ts
like below:
import { NextAuthConfig } from "next-auth";
export const authConfig = {
pages: {
signIn: "/login",
newUser: "/",
},
providers: [
// added later in auth.ts since it requires bcrypt which is only compatible with Node.js
// while this file is also used in non-Node.js environments
],
callbacks: {
authorized({ auth, request: { nextUrl } }) {
let isLoggedIn = !!auth?.user;
// let isOnChat = nextUrl.pathname.startsWith("/");
let isOnRegister = nextUrl.pathname.startsWith("/register");
let isOnLogin = nextUrl.pathname.startsWith("/login");
if (isLoggedIn && (isOnLogin || isOnRegister)) {
return Response.redirect(new URL("/", nextUrl));
}
if (isOnRegister || isOnLogin) {
return true; // Always allow access to register and login pages
}
// if (isOnChat) {
// if (isLoggedIn) return true;
// return false; // Redirect unauthenticated users to login page
// }
// if (isLoggedIn) {
// return Response.redirect(new URL("/", nextUrl));
// }
return true;
},
},
} satisfies NextAuthConfig;
Furthermore, I would make sure you ease the authentication checks in the route handlers based on your needs.
Hello! @jeremyphilemon
I gave it a shot but for some reason, when I check it now - although the signup screen doesn't show up, the chat is glitching. What I mean by glitching is that if I type in a response, it's not going through :(
What do you think I should be doingg?
Hello! Teams,
Hope you're doing great!
Small Q: how do I make it so that even unauthenticated users, can see the chat interface, w/o needing to log-in first?
I tried this:
Didn't quite work :(
Please do LMK how to proceed!
CC: @jeremyphilemon