an app to share curated trails
sidetrail.app
1"use client";
2
3import { useLoginModal } from "@/app/LoginModalContext";
4import { useAuthContext } from "@/app/AuthContext";
5
6export class AuthRequiredError extends Error {
7 constructor() {
8 super("Authentication required");
9 this.name = "AuthRequiredError";
10 }
11}
12
13export function useAuthAction() {
14 const { openLoginModal } = useLoginModal();
15 const { did } = useAuthContext();
16
17 return () => {
18 if (!did) {
19 openLoginModal();
20 throw new AuthRequiredError();
21 }
22 };
23}