Skip to content

Commit

Permalink
chore(server): register user management resolver (#7118)
Browse files Browse the repository at this point in the history
  • Loading branch information
forehalo committed Jun 3, 2024
1 parent 798af4e commit 06534bb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/backend/server/src/core/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { Module } from '@nestjs/common';

import { StorageModule } from '../storage';
import { UserAvatarController } from './controller';
import { UserResolver } from './resolver';
import { UserManagementResolver, UserResolver } from './resolver';
import { UserService } from './service';

@Module({
imports: [StorageModule],
providers: [UserResolver, UserService],
providers: [UserResolver, UserService, UserManagementResolver],
controllers: [UserAvatarController],
exports: [UserService],
})
Expand Down
11 changes: 6 additions & 5 deletions packages/backend/server/src/core/user/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ import { PrismaClient } from '@prisma/client';
import GraphQLUpload from 'graphql-upload/GraphQLUpload.mjs';
import { isNil, omitBy } from 'lodash-es';

import type { Config, CryptoHelper, FileUpload } from '../../fundamentals';
import { Throttle } from '../../fundamentals';
import {
Config,
CryptoHelper,
type FileUpload,
Throttle,
} from '../../fundamentals';
import { CurrentUser } from '../auth/current-user';
import { Public } from '../auth/guard';
import { sessionUser } from '../auth/service';
Expand Down Expand Up @@ -158,9 +162,6 @@ class CreateUserInput {

@Field(() => String, { nullable: true })
password!: string | null;

@Field(() => Boolean, { nullable: true, defaultValue: true })
requireEmailVerification!: boolean;
}

@Admin()
Expand Down
23 changes: 23 additions & 0 deletions packages/backend/server/src/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ input CreateCopilotPromptInput {
name: String!
}

input CreateUserInput {
email: String!
name: String
password: String
}

type CredentialsRequirementType {
password: PasswordLimitsType!
}
Expand Down Expand Up @@ -233,6 +239,11 @@ type LimitedUserType {
hasPassword: Boolean
}

input ListUserInput {
first: Int = 20
skip: Int = 0
}

type Mutation {
acceptInviteById(inviteId: String!, sendAcceptMail: Boolean, workspaceId: String!): Boolean!
addAdminister(email: String!): Boolean!
Expand Down Expand Up @@ -260,10 +271,16 @@ type Mutation {
"""Create a stripe customer portal to manage payment methods"""
createCustomerPortal: String!

"""Create a new user"""
createUser(input: CreateUserInput!): UserType!

"""Create a new workspace"""
createWorkspace(init: Upload): WorkspaceType!
deleteAccount: DeleteAccount!
deleteBlob(hash: String!, workspaceId: String!): Boolean!

"""Delete a user account"""
deleteUser(id: String!): DeleteAccount!
deleteWorkspace(id: String!): Boolean!
invite(email: String!, permission: Permission!, sendInviteMail: Boolean, workspaceId: String!): String!
leaveWorkspace(sendLeaveMail: Boolean, workspaceId: String!, workspaceName: String!): Boolean!
Expand Down Expand Up @@ -362,6 +379,12 @@ type Query {
"""Get user by email"""
user(email: String!): UserOrLimitedUser

"""Get user by id"""
userById(id: String!): UserType!

"""List registered users"""
users(filter: ListUserInput!): [UserType!]!

"""Get workspace by id"""
workspace(id: String!): WorkspaceType!

Expand Down

0 comments on commit 06534bb

Please sign in to comment.