Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 회원가입시 이메일과 비밀번호 보안 개선 #540

Merged
merged 5 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"tsconfig-paths": "^4.1.1",
"typeorm": "^0.3.11",
"typeorm-model-generator": "^0.4.6",
"uuid": "^9.0.0",
middlefitting marked this conversation as resolved.
Show resolved Hide resolved
"winston": "^3.6.0",
"winston-daily-rotate-file": "^4.6.1",
"zod": "^3.21.4"
Expand Down
3 changes: 2 additions & 1 deletion backend/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as bcrypt from 'bcrypt';
import { NextFunction, Request, Response } from 'express';
import * as status from 'http-status';
import { randomUUID } from 'crypto';
middlefitting marked this conversation as resolved.
Show resolved Hide resolved
import * as models from '../DTO/users.model';
import { oauth42ApiOption, oauthUrlOption } from '../config';
import { updateSlackIdByUserId } from '../slack/slack.service';
Expand Down Expand Up @@ -30,7 +31,7 @@ export const getToken = async (req: Request, res: Response, next: NextFunction):
// 회원가입
try {
const email = `${nickName}@student.42seoul.kr`;
await usersService.createUser(String(email), await bcrypt.hash(String(email), 10));
await usersService.createUser(String(email), await bcrypt.hash(randomUUID(), 10));
const newUser: { items: models.User[] } = await usersService.searchUserByEmail(email);
await authService.updateAuthenticationUser(newUser.items[0].id, id, nickName);
await updateSlackIdByUserId(newUser.items[0].id);
Expand Down
2 changes: 1 addition & 1 deletion backend/src/routes/users.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export const router = Router();
* application/json:
* schema:
* type: object
* description: 200, 201, 205 에러 가능
* description: 200, 201, 205, 209 에러 가능
* properties:
* errorCode:
* type: number
Expand Down
4 changes: 4 additions & 0 deletions backend/src/users/users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ export const create = async (req: Request, res: Response, next: NextFunction) =>
if (!email || !password) {
return next(new ErrorResponse(errorCode.INVALID_INPUT, status.BAD_REQUEST));
}
const regex = /@student\.42seoul\.kr$/;
if (regex.test(email)) {
return next(new ErrorResponse(errorCode.INVALID_INPUT, status.BAD_REQUEST));
middlefitting marked this conversation as resolved.
Show resolved Hide resolved
}
try {
pwSchema
.is().min(10)
Expand Down
1 change: 1 addition & 0 deletions backend/src/utils/error/errorCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const INVALIDATE_PASSWORD = '205';
export const INVALID_ROLE = '206';
export const SLACK_OVERLAP = '207';
export const INTRA_AUTHENTICATE_SUCCESS = '208';
export const STUDENT_42_SUBSCRIPTION_FORBIDDEN = '209';

export const SLACKID_OVERLAP = '301';
export const NO_ISBN = '302';
Expand Down