Made it So That You Can Go to the 'Marketing' If You Are Logged In

This commit is contained in:
Ahmad 2024-02-21 18:14:33 -05:00
parent c3776e8874
commit fe272499f8
No known key found for this signature in database
GPG key ID: 8FD8A93530D182BF
8 changed files with 55 additions and 50 deletions

View file

@ -4,17 +4,6 @@ import { NextResponse } from 'next/server';
export default authMiddleware({
publicRoutes: ['/', '/api/webhook', '/privacy-policy', '/terms-of-service'],
afterAuth(auth, req) {
if (auth.userId && auth.isPublicRoute) {
let path = '/select-org';
if (auth.orgId) {
path = `/organization/${auth.orgId}`;
}
const orgSelection = new URL(path, req.url);
return NextResponse.redirect(orgSelection);
}
if (!auth.userId && !auth.isPublicRoute) {
return redirectToSignIn({ returnBackUrl: req.url });
}