Skip to content

Commit

Permalink
feat: authorized access
Browse files Browse the repository at this point in the history
  • Loading branch information
Sid-80 committed Jun 15, 2024
1 parent 27e85fd commit 1753f2f
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions src/app/invite/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ export default function Page({ params }: any) {
setIsValidLink(false);
}
};
if (user && isAuthenticated) {
getTeamData();
}
if(!user && !isAuthenticated && !teamData && !isError){
setIsDialogOpen(true)
}
}, [user]);

getTeamData();
}, []);

const AddUserToMember = async () => {
if (!user || !isAuthenticated) {
setErrorMsg("Unauthorized Access!");
setIsError(true);
return;
}

if (
teamData.teamMembers?.includes(user.email) ||
teamData.createdBy == user.email
Expand Down Expand Up @@ -189,20 +189,14 @@ export default function Page({ params }: any) {
</AlertDialogFooter>
</>
)}
{(!user && !isAuthenticated) && (
{isError && isDialogOpen && (
<>
<AlertDialogHeader>
<AlertDialogTitle>
Unauthorized Access or Invalid link!!
</AlertDialogTitle>
<AlertDialogDescription className="w-full">
<p>Register or Login to your account.</p>
<p>Link may be Invalid!</p>
</AlertDialogDescription>
<AlertDialogTitle>{errorMsg}</AlertDialogTitle>
</AlertDialogHeader>
<AlertDialogFooter>
<Link
className="bg-primary p-2 rounded-lg px-3 text-secondary"
className="bg-primary text-white p-2 rounded-lg px-3 text-secondary"
href={"/"}
>
Home
Expand Down

0 comments on commit 1753f2f

Please sign in to comment.