mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-10 10:36:38 -06:00
Move repository into a monorepo with turborepo and pnpm. This is a big change in the way the code is organized, used and deployed.
22 lines
490 B
TypeScript
22 lines
490 B
TypeScript
import { signIn, useSession } from "next-auth/react";
|
|
import Loading from "../Loading";
|
|
|
|
const withAuthentication = (Component) =>
|
|
function WithAuth(props) {
|
|
const { status } = useSession({
|
|
required: true,
|
|
onUnauthenticated() {
|
|
// The user is not authenticated, handle it here.
|
|
return signIn();
|
|
},
|
|
});
|
|
|
|
if (status === "loading") {
|
|
return <Loading />;
|
|
}
|
|
|
|
return <Component {...props} />;
|
|
};
|
|
|
|
export default withAuthentication;
|