Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `wa_user_created` PostHog event fired on successful user sign-up. [#933](https://github.com/sourcebot-dev/sourcebot/pull/933)
- Added `wa_askgh_login_wall_prompted` PostHog event fired when an unauthenticated user attempts to ask a question on Ask GitHub. [#933](https://github.com/sourcebot-dev/sourcebot/pull/933)
- Added Bitbucket Server (Data Center) OAuth 2.0 SSO identity provider support (`provider: "bitbucket-server"`). [#934](https://github.com/sourcebot-dev/sourcebot/pull/934)
- Added `GET /api/ee/user` endpoint that returns the authenticated owner's user info (name, email, createdAt, updatedAt). [#940](https://github.com/sourcebot-dev/sourcebot/pull/940)

### Changed
- Hide version upgrade toast for askgithub deployment (`EXPERIMENT_ASK_GH_ENABLED`). [#931](https://github.com/sourcebot-dev/sourcebot/pull/931)
Expand Down
35 changes: 35 additions & 0 deletions packages/web/src/app/api/(server)/ee/user/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,41 @@ import { NextRequest } from "next/server";
const logger = createLogger('ee-user-api');
const auditService = getAuditService();

export const GET = apiHandler(async () => {
const result = await withAuthV2(async ({ org, role, user, prisma }) => {
return withMinimumOrgRole(role, OrgRole.OWNER, async () => {
try {
const userData = await prisma.user.findUnique({
where: {
id: user.id,
},
select: {
name: true,
email: true,
createdAt: true,
updatedAt: true,
},
});

if (!userData) {
return notFound('User not found');
}
Comment thread
msukkari marked this conversation as resolved.

return userData;
} catch (error) {
logger.error('Error fetching user info', { error, userId: user.id });
throw error;
}
});
});

if (isServiceError(result)) {
return serviceErrorResponse(result);
}

return Response.json(result, { status: StatusCodes.OK });
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

export const DELETE = apiHandler(async (request: NextRequest) => {
const url = new URL(request.url);
const userId = url.searchParams.get('userId');
Expand Down
Loading