chore(server): register user management resolver (#7118)

This commit is contained in:
forehalo
2024-06-03 06:52:18 +00:00
parent 798af4efee
commit 06534bbc06
3 changed files with 31 additions and 7 deletions

View File

@@ -2,12 +2,12 @@ import { Module } from '@nestjs/common';
import { StorageModule } from '../storage'; import { StorageModule } from '../storage';
import { UserAvatarController } from './controller'; import { UserAvatarController } from './controller';
import { UserResolver } from './resolver'; import { UserManagementResolver, UserResolver } from './resolver';
import { UserService } from './service'; import { UserService } from './service';
@Module({ @Module({
imports: [StorageModule], imports: [StorageModule],
providers: [UserResolver, UserService], providers: [UserResolver, UserService, UserManagementResolver],
controllers: [UserAvatarController], controllers: [UserAvatarController],
exports: [UserService], exports: [UserService],
}) })

View File

@@ -13,8 +13,12 @@ import { PrismaClient } from '@prisma/client';
import GraphQLUpload from 'graphql-upload/GraphQLUpload.mjs'; import GraphQLUpload from 'graphql-upload/GraphQLUpload.mjs';
import { isNil, omitBy } from 'lodash-es'; import { isNil, omitBy } from 'lodash-es';
import type { Config, CryptoHelper, FileUpload } from '../../fundamentals'; import {
import { Throttle } from '../../fundamentals'; Config,
CryptoHelper,
type FileUpload,
Throttle,
} from '../../fundamentals';
import { CurrentUser } from '../auth/current-user'; import { CurrentUser } from '../auth/current-user';
import { Public } from '../auth/guard'; import { Public } from '../auth/guard';
import { sessionUser } from '../auth/service'; import { sessionUser } from '../auth/service';
@@ -158,9 +162,6 @@ class CreateUserInput {
@Field(() => String, { nullable: true }) @Field(() => String, { nullable: true })
password!: string | null; password!: string | null;
@Field(() => Boolean, { nullable: true, defaultValue: true })
requireEmailVerification!: boolean;
} }
@Admin() @Admin()

View File

@@ -108,6 +108,12 @@ input CreateCopilotPromptInput {
name: String! name: String!
} }
input CreateUserInput {
email: String!
name: String
password: String
}
type CredentialsRequirementType { type CredentialsRequirementType {
password: PasswordLimitsType! password: PasswordLimitsType!
} }
@@ -233,6 +239,11 @@ type LimitedUserType {
hasPassword: Boolean hasPassword: Boolean
} }
input ListUserInput {
first: Int = 20
skip: Int = 0
}
type Mutation { type Mutation {
acceptInviteById(inviteId: String!, sendAcceptMail: Boolean, workspaceId: String!): Boolean! acceptInviteById(inviteId: String!, sendAcceptMail: Boolean, workspaceId: String!): Boolean!
addAdminister(email: String!): Boolean! addAdminister(email: String!): Boolean!
@@ -260,10 +271,16 @@ type Mutation {
"""Create a stripe customer portal to manage payment methods""" """Create a stripe customer portal to manage payment methods"""
createCustomerPortal: String! createCustomerPortal: String!
"""Create a new user"""
createUser(input: CreateUserInput!): UserType!
"""Create a new workspace""" """Create a new workspace"""
createWorkspace(init: Upload): WorkspaceType! createWorkspace(init: Upload): WorkspaceType!
deleteAccount: DeleteAccount! deleteAccount: DeleteAccount!
deleteBlob(hash: String!, workspaceId: String!): Boolean! deleteBlob(hash: String!, workspaceId: String!): Boolean!
"""Delete a user account"""
deleteUser(id: String!): DeleteAccount!
deleteWorkspace(id: String!): Boolean! deleteWorkspace(id: String!): Boolean!
invite(email: String!, permission: Permission!, sendInviteMail: Boolean, workspaceId: String!): String! invite(email: String!, permission: Permission!, sendInviteMail: Boolean, workspaceId: String!): String!
leaveWorkspace(sendLeaveMail: Boolean, workspaceId: String!, workspaceName: String!): Boolean! leaveWorkspace(sendLeaveMail: Boolean, workspaceId: String!, workspaceName: String!): Boolean!
@@ -362,6 +379,12 @@ type Query {
"""Get user by email""" """Get user by email"""
user(email: String!): UserOrLimitedUser user(email: String!): UserOrLimitedUser
"""Get user by id"""
userById(id: String!): UserType!
"""List registered users"""
users(filter: ListUserInput!): [UserType!]!
"""Get workspace by id""" """Get workspace by id"""
workspace(id: String!): WorkspaceType! workspace(id: String!): WorkspaceType!