Skip to content

Commit e1a7d0d

Browse files
committed
feedback
1 parent 4b68ed9 commit e1a7d0d

File tree

7 files changed

+19
-139
lines changed

7 files changed

+19
-139
lines changed

docs/docs/configuration/auth/overview.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Sourcebot's built-in authentication system gates your deployment, and allows adm
1010
<Card horizontal title="Authentication providers" icon="lock" href="/docs/configuration/auth/providers">
1111
Configure additional authentication providers for your deployment.
1212
</Card>
13-
<Card horizontal title="Inviting members" icon="user" href="/docs/configuration/auth/providers">
13+
<Card horizontal title="Inviting members" icon="user" href="/docs/configuration/auth/inviting-members">
1414
Learn how to configure how members join your deployment.
1515
</Card>
1616
<Card horizontal title="Roles and permissions" icon="shield" href="/docs/configuration/auth/roles-and-permissions">

packages/web/src/actions.ts

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,19 +1142,11 @@ export const cancelInvite = async (inviteId: string, domain: string): Promise<{
11421142
));
11431143

11441144
export const getOrgInviteId = async (domain: string) => sew(() =>
1145-
withAuth(async () => {
1146-
const org = await prisma.org.findUnique({
1147-
where: {
1148-
domain: domain,
1149-
},
1150-
});
1151-
1152-
if (!org) {
1153-
return notFound();
1154-
}
1155-
1156-
return org.inviteLinkId;
1157-
}));
1145+
withAuth(async (userId) =>
1146+
withOrgMembership(userId, domain, async ({ org }) => {
1147+
return org.inviteLinkId;
1148+
}, /* minRequiredRole = */ OrgRole.OWNER)
1149+
));
11581150

11591151
export const getMe = async () => sew(() =>
11601152
withAuth(async (userId) => {
@@ -1443,19 +1435,6 @@ export const removeMemberFromOrg = async (memberId: string, domain: string): Pro
14431435
}
14441436
});
14451437

1446-
// TODO: The fact that pendingApproval is set in the user is a bit weird here, since it will prevent approval from working in the multi-tenant case.
1447-
// We need to set pendingApproval to be true here though so that if the user tries to sign into the deployment again it will send another request. Without
1448-
// this, the user will never be able to request to join the org again.
1449-
// TODO(multitenant): Handle this better
1450-
await tx.user.update({
1451-
where: {
1452-
id: memberId,
1453-
},
1454-
data: {
1455-
pendingApproval: true,
1456-
}
1457-
});
1458-
14591438
if (IS_BILLING_ENABLED) {
14601439
const result = await decrementOrgSeatCount(org.id, tx);
14611440
if (isServiceError(result)) {
@@ -1601,14 +1580,6 @@ export const createAccountRequest = async (userId: string, domain: string) => se
16011580
return notFound("User not found");
16021581
}
16031582

1604-
if (user.pendingApproval == false) {
1605-
logger.warn(`User ${userId} isn't pending approval. Skipping account request creation.`);
1606-
return {
1607-
success: true,
1608-
existingRequest: false,
1609-
}
1610-
}
1611-
16121583
const org = await prisma.org.findUnique({
16131584
where: {
16141585
domain,

packages/web/src/app/[domain]/components/resubmitAccountRequestButton.tsx

Lines changed: 0 additions & 64 deletions
This file was deleted.

packages/web/src/app/[domain]/components/submitAccountRequestButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export function SubmitAccountRequestButton({ domain, userId }: SubmitButtonProps
4343
description: `There was an error submitting your request. Reason: ${result.message}`,
4444
variant: "destructive",
4545
})
46-
setIsSubmitting(false)
4746
}
47+
setIsSubmitting(false)
4848
}
4949

5050
return (

packages/web/src/app/components/providerButton.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { LoadingButton } from "@/components/ui/loading-button";
88
interface ProviderButtonProps {
99
name: string;
1010
logo: { src: string, className?: string } | null;
11-
onClick: () => void;
11+
onClick: () => void | Promise<void>;
1212
className?: string;
1313
context: "login" | "signup";
1414
}
@@ -22,12 +22,18 @@ export const ProviderButton = ({
2222
}: ProviderButtonProps) => {
2323
const [isLoading, setIsLoading] = useState(false);
2424

25+
const handleClick = async () => {
26+
setIsLoading(true);
27+
try {
28+
await onClick();
29+
} finally {
30+
setIsLoading(false);
31+
}
32+
};
33+
2534
return (
2635
<LoadingButton
27-
onClick={() => {
28-
setIsLoading(true);
29-
onClick();
30-
}}
36+
onClick={handleClick}
3137
className={cn("w-full", className)}
3238
variant="outline"
3339
loading={isLoading}

packages/web/src/app/invite/page.tsx

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -57,37 +57,6 @@ export default async function InvitePage({ searchParams }: InvitePageProps) {
5757
);
5858
}
5959

60-
function InvalidInviteCard({ message }: { message: string }) {
61-
return (
62-
<div className="min-h-screen bg-gradient-to-br from-[var(--background)] to-[var(--accent)]/30 flex items-center justify-center p-6">
63-
<Card className="w-full max-w-md">
64-
<CardHeader className="text-center">
65-
<SourcebotLogo className="h-12 mb-4 mx-auto" size="large" />
66-
<CardTitle className="text-xl font-semibold text-[var(--destructive)]">
67-
Invalid Invitation
68-
</CardTitle>
69-
</CardHeader>
70-
<CardContent className="text-center space-y-4">
71-
<p className="text-[var(--muted-foreground)]">
72-
{message}
73-
</p>
74-
<div className="p-4 rounded-lg bg-[var(--destructive)]/10 border border-[var(--destructive)]/20">
75-
<p className="text-sm text-[var(--destructive)] flex items-center gap-2">
76-
<svg className="w-4 h-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
77-
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16c-.77.833.192 2.5 1.732 2.5z" />
78-
</svg>
79-
Please contact your administrator for a valid invitation link.
80-
</p>
81-
</div>
82-
<Button asChild className="w-full">
83-
<a href="/login">Return to Login</a>
84-
</Button>
85-
</CardContent>
86-
</Card>
87-
</div>
88-
);
89-
}
90-
9160
function WelcomeCard({ inviteLinkId, providers }: { inviteLinkId: string; providers: import("@/lib/authProviders").AuthProvider[] }) {
9261
return (
9362
<div className="min-h-screen bg-gradient-to-br from-[var(--background)] to-[var(--accent)]/30 flex items-center justify-center p-6">

packages/web/src/app/onboard/components/memberApprovalRequiredToggle.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ import { isServiceError } from "@/lib/utils"
99
import { useToast } from "@/components/hooks/use-toast"
1010
import { InviteLinkToggle } from "@/app/components/inviteLinkToggle"
1111

12-
interface MemberApprovalRequiredToggleProps {}
13-
14-
export function MemberApprovalRequiredToggle({}: MemberApprovalRequiredToggleProps) {
12+
export function MemberApprovalRequiredToggle() {
1513
const [enabled, setEnabled] = useState(false)
1614
const [isLoading, setIsLoading] = useState(false)
1715
const [isInitializing, setIsInitializing] = useState(true)

0 commit comments

Comments
 (0)