diff --git a/apps/api/src/services/orgs/invites.py b/apps/api/src/services/orgs/invites.py index e66439d8..5b2ab948 100644 --- a/apps/api/src/services/orgs/invites.py +++ b/apps/api/src/services/orgs/invites.py @@ -240,12 +240,14 @@ async def delete_invite_code( ) # Delete invite code - invite_code = r.delete(f"{invite_code_uuid}:org:{org.org_uuid}:code:*") + keys = r.keys(f"{invite_code_uuid}:org:{org.org_uuid}:code:*") + if keys: + r.delete(*keys) - if not invite_code: + if not keys: raise HTTPException( status_code=404, detail="Invite code not found", ) - return invite_code + return keys diff --git a/apps/web/app/orgs/[orgslug]/login/page.tsx b/apps/web/app/orgs/[orgslug]/login/page.tsx index 11dd3f5b..faf71cc8 100644 --- a/apps/web/app/orgs/[orgslug]/login/page.tsx +++ b/apps/web/app/orgs/[orgslug]/login/page.tsx @@ -12,7 +12,7 @@ export async function generateMetadata( ): Promise { const orgslug = params.orgslug; // Get Org context information - const org = await getOrganizationContextInfo(orgslug, { revalidate: 1800, tags: ['organizations'] }); + const org = await getOrganizationContextInfo(orgslug, { revalidate: 0, tags: ['organizations'] }); return { title: 'Login' + ` — ${org.name}`, @@ -21,7 +21,7 @@ export async function generateMetadata( const Login = async (params: any) => { const orgslug = params.params.orgslug; - const org = await getOrganizationContextInfo(orgslug, { revalidate: 1800, tags: ['organizations'] }); + const org = await getOrganizationContextInfo(orgslug, { revalidate: 0, tags: ['organizations'] }); return (
diff --git a/apps/web/app/orgs/[orgslug]/signup/page.tsx b/apps/web/app/orgs/[orgslug]/signup/page.tsx index afe3f569..d5ea7431 100644 --- a/apps/web/app/orgs/[orgslug]/signup/page.tsx +++ b/apps/web/app/orgs/[orgslug]/signup/page.tsx @@ -15,7 +15,7 @@ export async function generateMetadata( ): Promise { const orgslug = params.orgslug; // Get Org context information - const org = await getOrganizationContextInfo(orgslug, { revalidate: 1800, tags: ['organizations'] }); + const org = await getOrganizationContextInfo(orgslug, { revalidate: 0, tags: ['organizations'] }); return { title: 'Sign up' + ` — ${org.name}`, @@ -24,7 +24,7 @@ export async function generateMetadata( const SignUp = async (params: any) => { const orgslug = params.params.orgslug; - const org = await getOrganizationContextInfo(orgslug, { revalidate: 1800, tags: ['organizations'] }); + const org = await getOrganizationContextInfo(orgslug, { revalidate: 0, tags: ['organizations'] }); return ( <> diff --git a/apps/web/app/orgs/[orgslug]/signup/signup.tsx b/apps/web/app/orgs/[orgslug]/signup/signup.tsx index 876dfb06..fec32b1a 100644 --- a/apps/web/app/orgs/[orgslug]/signup/signup.tsx +++ b/apps/web/app/orgs/[orgslug]/signup/signup.tsx @@ -19,28 +19,28 @@ import toast from "react-hot-toast"; interface SignUpClientProps { org: any; - } +} -function SignUpClient(props : SignUpClientProps) { +function SignUpClient(props: SignUpClientProps) { const session = useSession() as any; const [joinMethod, setJoinMethod] = React.useState('open'); - const [inviteCode , setInviteCode] = React.useState(''); + const [inviteCode, setInviteCode] = React.useState(''); const searchParams = useSearchParams() const inviteCodeParam = searchParams.get('inviteCode') useEffect(() => { - if (props.org.config){ + if (props.org.config) { setJoinMethod(props.org?.config?.config?.GeneralConfig.users.signup_mechanism); console.log(props.org?.config?.config?.GeneralConfig.users.signup_mechanism) } - if (inviteCodeParam){ + if (inviteCodeParam) { setInviteCode(inviteCodeParam); } } - , [props.org,inviteCodeParam]); + , [props.org, inviteCodeParam]); return ( -
+
@@ -67,13 +67,17 @@ function SignUpClient(props : SignUpClientProps) {
- {joinMethod == 'open' && } - {joinMethod == 'inviteOnly' && inviteCode && session.isAuthenticated && } - {joinMethod == 'inviteOnly' && inviteCode && !session.isAuthenticated && } - {joinMethod == 'inviteOnly' && !inviteCode && } + {joinMethod == 'open' && ( + session.isAuthenticated ? : + )} + {joinMethod == 'inviteOnly' && ( + inviteCode ? ( + session.isAuthenticated ? : + ) : + )}
- ) + ) } @@ -86,29 +90,29 @@ const LoggedInJoinScreen = (props: any) => { const [isLoading, setIsLoading] = React.useState(true); useEffect(() => { - if(session && org){ + if (session && org) { setIsLoading(false); } - - } - , [org, session]); + + } + , [org, session]); return (
-

- Hi - +

+ Hi + - {session.user.username}, - - join {org?.name} ? -

- +
) @@ -120,7 +124,7 @@ const NoTokenScreen = (props: any) => { const org = useOrg() as any; const router = useRouter(); const [isLoading, setIsLoading] = React.useState(true); - const [inviteCode , setInviteCode] = React.useState(''); + const [inviteCode, setInviteCode] = React.useState(''); const [messsage, setMessage] = React.useState('bruh'); const handleInviteCodeChange = (e: any) => { @@ -129,12 +133,12 @@ const NoTokenScreen = (props: any) => { const validateCode = async () => { setIsLoading(true); - let res = await validateInviteCode(org?.id,inviteCode); + let res = await validateInviteCode(org?.id, inviteCode); //wait for 1s if (res.success) { - toast.success("Invite code is valid, you'll be redirected to the signup page in a few seconds"); + toast.success("Invite code is valid, you'll be redirected to the signup page in a few seconds"); setTimeout(() => { - router.push(`/signup?inviteCode=${inviteCode}`); + router.push(`/signup?inviteCode=${inviteCode}`); }, 2000); } else { @@ -146,28 +150,28 @@ const NoTokenScreen = (props: any) => { useEffect(() => { - if(session && org){ + if (session && org) { setIsLoading(false); } - - } - , [org, session]); + + } + , [org, session]); return (
- - {isLoading ?
:
- -

- - An invite code is required to join {org?.name} -

- - -
} + +
}
) }