Skip to content

[admin] Allow manual user verification #12542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions components/dashboard/src/admin/UserDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ export default function UserDetail(p: { user: User }) {
});
};

const verifyUser = async () => {
await updateUser(async (u) => {
return await getGitpodService().server.adminVerifyUser(u.id);
});
};

const toggleBlockUser = async () => {
await updateUser(async (u) => {
u.blocked = !u.blocked;
Expand Down Expand Up @@ -132,6 +138,11 @@ export default function UserDetail(p: { user: User }) {
.join(", ")}
</p>
</div>
{!user.lastVerificationTime ? (
<button className="secondary danger ml-3" disabled={activity} onClick={verifyUser}>
Verify User
</button>
) : null}
<button className="secondary danger ml-3" disabled={activity} onClick={toggleBlockUser}>
{user.blocked ? "Unblock" : "Block"} User
</button>
Expand Down
1 change: 1 addition & 0 deletions components/gitpod-protocol/src/admin-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface AdminServer {
adminGetUser(id: string): Promise<User>;
adminBlockUser(req: AdminBlockUserRequest): Promise<User>;
adminDeleteUser(id: string): Promise<void>;
adminVerifyUser(id: string): Promise<User>;
adminModifyRoleOrPermission(req: AdminModifyRoleOrPermissionRequest): Promise<User>;
adminModifyPermanentWorkspaceFeatureFlag(req: AdminModifyPermanentWorkspaceFeatureFlagRequest): Promise<User>;

Expand Down
17 changes: 17 additions & 0 deletions components/server/ee/src/workspace/gitpod-server-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,23 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
return this.censorUser(targetUser);
}

async adminVerifyUser(ctx: TraceContext, userId: string): Promise<User> {
await this.requireEELicense(Feature.FeatureAdminDashboard);

await this.guardAdminAccess("adminVerifyUser", { id: userId }, Permission.ADMIN_USERS);
try {
const user = await this.userDB.findUserById(userId);
if (!user) {
throw new ResponseError(ErrorCodes.NOT_FOUND, `No user with id ${userId} found.`);
}
this.verificationService.markVerified(user);
await this.userDB.updateUserPartial(user);
return user;
} catch (e) {
throw new ResponseError(ErrorCodes.INTERNAL_SERVER_ERROR, e.toString());
}
}

async adminDeleteUser(ctx: TraceContext, userId: string): Promise<void> {
traceAPIParams(ctx, { userId });

Expand Down
1 change: 1 addition & 0 deletions components/server/src/auth/rate-limiter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ function getConfig(config: RateLimiterConfig): RateLimiterConfig {
adminGetUser: { group: "default", points: 1 },
adminBlockUser: { group: "default", points: 1 },
adminDeleteUser: { group: "default", points: 1 },
adminVerifyUser: { group: "default", points: 1 },
adminModifyRoleOrPermission: { group: "default", points: 1 },
adminModifyPermanentWorkspaceFeatureFlag: { group: "default", points: 1 },
adminGetTeams: { group: "default", points: 1 },
Expand Down
4 changes: 4 additions & 0 deletions components/server/src/workspace/gitpod-server-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2695,6 +2695,10 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
throw new ResponseError(ErrorCodes.EE_FEATURE, `Admin support is implemented in Gitpod's Enterprise Edition`);
}

async adminVerifyUser(ctx: TraceContext, _id: string): Promise<User> {
throw new ResponseError(ErrorCodes.EE_FEATURE, `Admin support is implemented in Gitpod's Enterprise Edition`);
}

async adminModifyRoleOrPermission(ctx: TraceContext, req: AdminModifyRoleOrPermissionRequest): Promise<User> {
throw new ResponseError(ErrorCodes.EE_FEATURE, `Admin support is implemented in Gitpod's Enterprise Edition`);
}
Expand Down