Skip to content

Commit 1ba266a

Browse files
committed
feedback
1 parent e1a7d0d commit 1ba266a

File tree

7 files changed

+29
-40
lines changed

7 files changed

+29
-40
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Fixed
1111
- Fixed issue with external source code links being broken for paths with spaces. [#364](https://github.com/sourcebot-dev/sourcebot/pull/364)
12+
- Revamped onboarding experience. [#370](https://github.com/sourcebot-dev/sourcebot/pull/376)
1213

1314
## [4.5.0] - 2025-06-21
1415

docs/docs/configuration/auth/inviting-members.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ There are various ways to configure how members can join a Sourcebot deployment.
77

88
## Member Approval
99

10-
**By default, Sourcebot requires new members to be approved by the owner of the deploymen**. This section explains how approvals work and how
10+
**By default, Sourcebot requires new members to be approved by the owner of the deployment**. This section explains how approvals work and how
1111
to configure this behavior.
1212

1313
### Configuration

packages/web/src/app/api/(server)/onboarded/route.ts

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

packages/web/src/app/invite/actions.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
import { withAuth } from "@/actions";
44
import { isServiceError } from "@/lib/utils";
5-
import { orgNotFound } from "@/lib/serviceError";
5+
import { orgNotFound, ServiceError } from "@/lib/serviceError";
66
import { sew } from "@/actions";
77
import { addUserToOrganization } from "@/lib/authUtils";
88
import { prisma } from "@/prisma";
9+
import { StatusCodes } from "http-status-codes";
10+
import { ErrorCode } from "@/lib/errorCodes";
911

10-
export const joinOrganization = (orgId: number) => sew(async () =>
12+
export const joinOrganization = (orgId: number, inviteLinkId: string) => sew(async () =>
1113
withAuth(async (userId) => {
1214
const org = await prisma.org.findUnique({
1315
where: {
@@ -19,6 +21,22 @@ export const joinOrganization = (orgId: number) => sew(async () =>
1921
return orgNotFound();
2022
}
2123

24+
if (!org.inviteLinkEnabled) {
25+
return {
26+
statusCode: StatusCodes.BAD_REQUEST,
27+
errorCode: ErrorCode.INVITE_LINK_NOT_ENABLED,
28+
message: "Invite link is not enabled.",
29+
} satisfies ServiceError;
30+
}
31+
32+
if (org.inviteLinkId !== inviteLinkId) {
33+
return {
34+
statusCode: StatusCodes.BAD_REQUEST,
35+
errorCode: ErrorCode.INVALID_INVITE_LINK,
36+
message: "Invalid invite link.",
37+
} satisfies ServiceError;
38+
}
39+
2240
const addUserToOrgRes = await addUserToOrganization(userId, org.id);
2341
if (isServiceError(addUserToOrgRes)) {
2442
return addUserToOrgRes;

packages/web/src/app/invite/components/joinOrganizationButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { joinOrganization } from "../actions";
99
import { isServiceError } from "@/lib/utils";
1010
import { SINGLE_TENANT_ORG_DOMAIN, SINGLE_TENANT_ORG_ID } from "@/lib/constants";
1111

12-
export function JoinOrganizationButton() {
12+
export function JoinOrganizationButton({ inviteLinkId }: { inviteLinkId: string }) {
1313
const [isLoading, setIsLoading] = useState(false);
1414
const router = useRouter();
1515
const { toast } = useToast();
@@ -18,7 +18,7 @@ export function JoinOrganizationButton() {
1818
setIsLoading(true);
1919

2020
try {
21-
const result = await joinOrganization(SINGLE_TENANT_ORG_ID);
21+
const result = await joinOrganization(SINGLE_TENANT_ORG_ID, inviteLinkId);
2222

2323
if (isServiceError(result)) {
2424
toast({

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default async function InvitePage({ searchParams }: InvitePageProps) {
5252
return (
5353
<div className="min-h-screen flex items-center justify-center p-6">
5454
<LogoutEscapeHatch className="absolute top-0 right-0 p-6" />
55-
<JoinInvitationCard />
55+
<JoinInvitationCard inviteLinkId={inviteLinkId} />
5656
</div>
5757
);
5858
}
@@ -86,7 +86,7 @@ function WelcomeCard({ inviteLinkId, providers }: { inviteLinkId: string; provid
8686
);
8787
}
8888

89-
function JoinInvitationCard() {
89+
function JoinInvitationCard({ inviteLinkId }: { inviteLinkId: string }) {
9090
return (
9191
<div className="min-h-screen bg-gradient-to-br from-[var(--background)] to-[var(--accent)]/30 flex items-center justify-center p-6">
9292
<Card className="w-full max-w-md">
@@ -99,7 +99,7 @@ function JoinInvitationCard() {
9999
Welcome to Sourcebot! Click the button below to join this organization.
100100
</p>
101101
</div>
102-
<JoinOrganizationButton />
102+
<JoinOrganizationButton inviteLinkId={inviteLinkId} />
103103
</CardContent>
104104
</Card>
105105
</div>

packages/web/src/lib/errorCodes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export enum ErrorCode {
1818
CONNECTION_ALREADY_EXISTS = 'CONNECTION_ALREADY_EXISTS',
1919
OWNER_CANNOT_LEAVE_ORG = 'OWNER_CANNOT_LEAVE_ORG',
2020
INVALID_INVITE = 'INVALID_INVITE',
21+
INVALID_INVITE_LINK = 'INVALID_INVITE_LINK',
22+
INVITE_LINK_NOT_ENABLED = 'INVITE_LINK_NOT_ENABLED',
2123
STRIPE_CHECKOUT_ERROR = 'STRIPE_CHECKOUT_ERROR',
2224
SECRET_ALREADY_EXISTS = 'SECRET_ALREADY_EXISTS',
2325
SUBSCRIPTION_ALREADY_EXISTS = 'SUBSCRIPTION_ALREADY_EXISTS',

0 commit comments

Comments
 (0)