From 88353f0db0493d3ce66e7e76c47d148a5fb7aa66 Mon Sep 17 00:00:00 2001 From: kwon-ga Date: Sat, 29 Oct 2022 13:59:26 +0900 Subject: [PATCH] =?UTF-8?q?#4=20=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20?= =?UTF-8?q?=EB=B0=8F=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app.ts b/app.ts index e353b93..679a3c1 100644 --- a/app.ts +++ b/app.ts @@ -8,8 +8,13 @@ import {User} from './src/entity/User'; require('dotenv').config(); - - +interface UserInterface { + userId?: number, + nickname: string, + password: string, + imgPath?: string, + refreshToken?: string +} app.use([ express.json(), @@ -29,7 +34,7 @@ app.post('/signup',async( req:Request, res:Response, next:NextFunction)=>{ user.password = hashPassword ; user.imgPath = imgPath ; - const result: object = await user.save(); // save 함수 자체가 느리다는 검색 결과가 있네요잉 + const result: UserInterface = await user.save(); // save 함수 자체가 느리다는 검색 결과가 있네요잉 // = const update = await User.save({firstName:firstName, lastName:lastName,isActive: true }) res.send({msg:'회원가입 완료!',data:result}) @@ -45,7 +50,7 @@ app.post('/login',async( req:Request, res:Response, next:NextFunction)=>{ const {email,password} = req.body; const user = new User(); - const findOneResult: object | null = await User.findOne({where:{ email:email }}); + const findOneResult: UserInterface | null = await User.findOne({where:{ email:email }}); if(!findOneResult) throw new Error('No content'); @@ -69,11 +74,12 @@ app.post('/login',async( req:Request, res:Response, next:NextFunction)=>{ expiresIn: '7h', }); - const hashtoken:string = await bcrypt.hash(password,10); + // refreshToken 암호화 제거 + // const hashtoken:string = await bcrypt.hash(password,10); const updateUser = await User.update( {userId:findOneResult['userId']}, - { refreshToken: hashtoken} + { refreshToken: refreshToken} ) if(!updateUser['affected']) throw new Error('refreshToken update error');