update Clerk V5
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import PageLayout from '@/app/(app)/[organizationSlug]/[projectId]/page-layout';
|
||||
import { auth } from '@clerk/nextjs';
|
||||
import { auth } from '@clerk/nextjs/server';
|
||||
|
||||
import { getUserById } from '@openpanel/db';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import type { OAuthStrategy } from '@/types';
|
||||
import { useSignIn } from '@clerk/nextjs';
|
||||
import type { OAuthStrategy } from '@clerk/nextjs/dist/types/server';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
import EmailSignUp from './email-sign-in';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { auth } from '@clerk/nextjs';
|
||||
import { auth } from '@clerk/nextjs/server';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
import PageClient from './page.client';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import type { OAuthStrategy } from '@/types';
|
||||
import { useSignUp } from '@clerk/nextjs';
|
||||
import type { OAuthStrategy } from '@clerk/nextjs/dist/types/server';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
import EmailSignUp from './email-sign-up';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { auth } from '@clerk/nextjs';
|
||||
import { auth } from '@clerk/nextjs/server';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
import PageClient from './page.client';
|
||||
|
||||
@@ -3,7 +3,12 @@ import { AuthenticateWithRedirectCallback } from '@clerk/nextjs';
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
const SSOCallback = () => {
|
||||
return <AuthenticateWithRedirectCallback />;
|
||||
return (
|
||||
<AuthenticateWithRedirectCallback
|
||||
signInUrl="/login"
|
||||
signUpUrl="/register"
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default SSOCallback;
|
||||
|
||||
@@ -1,12 +1,25 @@
|
||||
import { authMiddleware } from '@clerk/nextjs';
|
||||
import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server';
|
||||
|
||||
// This example protects all routes including api/trpc routes
|
||||
// Please edit this to allow other routes to be public as needed.
|
||||
// See https://clerk.com/docs/references/nextjs/auth-middleware for more information about configuring your Middleware
|
||||
export default authMiddleware({
|
||||
publicRoutes: ['/share/overview/:id', '/api/trpc(.*)', '/api/clerk/(.*)?'],
|
||||
debug: process.env.CLERK_DEBUG ? true : false,
|
||||
});
|
||||
const isPublicRoute = createRouteMatcher([
|
||||
'/share/overview/:id',
|
||||
'/api/clerk/(.*)?',
|
||||
'/login',
|
||||
'/register',
|
||||
]);
|
||||
|
||||
export default clerkMiddleware(
|
||||
(auth, req) => {
|
||||
if (!isPublicRoute(req)) {
|
||||
auth().protect();
|
||||
}
|
||||
},
|
||||
{
|
||||
debug: !!process.env.CLERK_DEBUG,
|
||||
}
|
||||
);
|
||||
|
||||
export const config = {
|
||||
matcher: [
|
||||
|
||||
@@ -7,3 +7,5 @@ export type HtmlProps<T> = Omit<
|
||||
export type IToolTipProps<T> = Omit<TooltipProps<number, string>, 'payload'> & {
|
||||
payload?: T[];
|
||||
};
|
||||
|
||||
export type OAuthStrategy = 'oauth_google' | 'oauth_github';
|
||||
|
||||
Reference in New Issue
Block a user