diff --git a/apps/server/src/auth/auth.controller.ts b/apps/server/src/auth/auth.controller.ts index e396a51..de67161 100755 --- a/apps/server/src/auth/auth.controller.ts +++ b/apps/server/src/auth/auth.controller.ts @@ -1,4 +1,19 @@ -import { Controller, Headers, Post, Body, UseGuards, Get, Req, HttpException, HttpStatus, BadRequestException, InternalServerErrorException, NotFoundException, UnauthorizedException, Logger } from '@nestjs/common'; +import { + Controller, + Headers, + Post, + Body, + UseGuards, + Get, + Req, + HttpException, + HttpStatus, + BadRequestException, + InternalServerErrorException, + NotFoundException, + UnauthorizedException, + Logger, +} from '@nestjs/common'; import { AuthService } from './auth.service'; import { AuthSchema, JwtPayload } from '@nice/common'; import { AuthGuard } from './auth.guard'; @@ -7,8 +22,8 @@ import { z } from 'zod'; import { FileValidationErrorType } from './types'; @Controller('auth') export class AuthController { - private logger = new Logger(AuthController.name) - constructor(private readonly authService: AuthService) { } + private logger = new Logger(AuthController.name); + constructor(private readonly authService: AuthService) {} @Get('file') async authFileRequset( @Headers('x-original-uri') originalUri: string, @@ -18,7 +33,6 @@ export class AuthController { @Headers('host') host: string, @Headers('authorization') authorization: string, ) { - try { const fileRequest = { originalUri, @@ -26,10 +40,11 @@ export class AuthController { method, queryParams, host, - authorization + authorization, }; - const authResult = await this.authService.validateFileRequest(fileRequest); + const authResult = + await this.authService.validateFileRequest(fileRequest); if (!authResult.isValid) { // 使用枚举类型进行错误处理 switch (authResult.error) { @@ -41,7 +56,9 @@ export class AuthController { case FileValidationErrorType.INVALID_TOKEN: throw new UnauthorizedException(authResult.error); default: - throw new InternalServerErrorException(authResult.error || FileValidationErrorType.UNKNOWN_ERROR); + throw new InternalServerErrorException( + authResult.error || FileValidationErrorType.UNKNOWN_ERROR, + ); } } return { @@ -51,17 +68,20 @@ export class AuthController { }, }; } catch (error: any) { - this.logger.verbose(`File request auth failed from ${realIp} reason:${error.message}`) + this.logger.verbose( + `File request auth failed from ${realIp} reason:${error.message}`, + ); throw error; } } @UseGuards(AuthGuard) @Get('user-profile') async getUserProfile(@Req() request: Request) { - const payload: JwtPayload = (request as any).user; - const { staff } = await UserProfileService.instance.getUserProfileById(payload.sub); - return staff + const { staff } = await UserProfileService.instance.getUserProfileById( + payload.sub, + ); + return staff; } @Post('login') async login(@Body() body: z.infer) { diff --git a/apps/server/src/auth/auth.service.ts b/apps/server/src/auth/auth.service.ts index 13025ee..4f0be21 100755 --- a/apps/server/src/auth/auth.service.ts +++ b/apps/server/src/auth/auth.service.ts @@ -146,6 +146,9 @@ export class AuthService { showname, photoUrl, deptId, + office, + email, + rank, ...others } = data; const existingUser = await db.staff.findFirst({ @@ -175,6 +178,9 @@ export class AuthService { // domainId: data.deptId, meta: { photoUrl, + office, + rank, + email, }, }, }); diff --git a/apps/web/src/app/auth/register.tsx b/apps/web/src/app/auth/register.tsx index b1c277e..18253f2 100644 --- a/apps/web/src/app/auth/register.tsx +++ b/apps/web/src/app/auth/register.tsx @@ -2,14 +2,21 @@ import AvatarUploader from "@web/src/components/common/uploader/AvatarUploader"; import DepartmentSelect from "@web/src/components/models/department/department-select"; import { Form, Input, Button, Select } from "antd"; import { motion } from "framer-motion"; +import { useState } from "react"; export interface RegisterFormData { deptId: string; + domainId: string; username: string; showname: string; + officerId: string; password: string; repeatPass: string; + rank: string; + office: string; + email: string; + phoneNumber: string; } interface RegisterFormProps { @@ -19,7 +26,7 @@ interface RegisterFormProps { export const RegisterForm = ({ onSubmit, isLoading }: RegisterFormProps) => { const [form] = Form.useForm(); - + const [domainId, setDomainId] = useState(); return ( {
@@ -62,67 +70,126 @@ export const RegisterForm = ({ onSubmit, isLoading }: RegisterFormProps) => { ]}> + + { + setDomainId(value as string); + }} + domain={true} + /> + - + - - - - - - - - - - ({ - validator(_, value) { - if ( - !value || - getFieldValue("password") === value - ) { - return Promise.resolve(); - } - return Promise.reject( - new Error("两次输入的密码不一致") - ); +
+ + + + - - + ]}> + + + + + + + + + + + + + + + ({ + validator(_, value) { + if ( + !value || + getFieldValue("password") === value + ) { + return Promise.resolve(); + } + return Promise.reject( + new Error("两次输入的密码不一致") + ); + }, + }), + ]}> + + +