Skip to content

Commit

Permalink
[BE#255] 이미지 null일때 분기처리
Browse files Browse the repository at this point in the history
  • Loading branch information
yeongbinim authored Nov 29, 2023
1 parent d062a0d commit 3cfa2c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 8 additions & 6 deletions BE/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
} from '@nestjs/swagger';
import { UsersService } from 'src/users/users.service';
import { UpdateUserDto } from 'src/users/dto/update-user.dto';
import { UsersModel } from 'src/users/entity/users.entity';
import { FileInterceptor } from '@nestjs/platform-express';
import { ConfigService } from '@nestjs/config';
import * as path from 'path';
Expand Down Expand Up @@ -80,14 +79,17 @@ export class AuthController {
@Body() user: UpdateUserDto,
@UploadedFile() file: Express.Multer.File,
): Promise<any> {
const isNomal = await this.usersService.isNormalImage(file);
if (!isNomal) {
throw new BadRequestException('유해한 이미지 입니다!!');
let image_url: string;
if (file) {
const isNomal = await this.usersService.isNormalImage(file);
if (!isNomal) {
throw new BadRequestException('유해한 이미지 입니다!!');
}
image_url = await this.usersService.s3Upload(file);
}
const image_url = await this.usersService.s3Upload(file);
const updatedUser = await this.usersService.updateUser(
user_id,
user as UsersModel,
user,
image_url,
);
return {
Expand Down
3 changes: 2 additions & 1 deletion BE/src/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { GreenEyeResponse } from './interface/greeneye.interface';
import { S3Service } from 'src/common/s3.service';
import * as path from 'path';
import { ENV } from 'src/common/const/env-keys.const';
import { UpdateUserDto } from './dto/update-user.dto';

@Injectable()
export class UsersService {
Expand Down Expand Up @@ -51,7 +52,7 @@ export class UsersService {

async updateUser(
user_id: number,
user: UsersModel,
user: UpdateUserDto,
image_url?: string,
): Promise<UsersModel> {
const selectedUser = await this.usersRepository.findOne({
Expand Down

0 comments on commit 3cfa2c8

Please sign in to comment.