Skip to content

Commit

Permalink
Merge pull request #21 from TeamBookTez/fix/signup-api
Browse files Browse the repository at this point in the history
Fix/signup api
  • Loading branch information
holmir97 authored Jan 12, 2022
2 parents 95844a9 + ce0aed3 commit 5b905fb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/controller/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const postLoginController = async (req: Request, res: Response) => {
}
};
const authController = {
postSignupController,
postSignupController,
postLoginController,
};

Expand Down
4 changes: 3 additions & 1 deletion src/router/auth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import express from "express";
import authController from "../controller/auth";
const router = express.Router();

// Controller
import authController from "../controller/auth";

router.post("/login", authController.postLoginController);
router.post("/signup", authController.postSignupController);

Expand Down
15 changes: 7 additions & 8 deletions src/service/auth.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// sequelize
import sequelize, { Op } from "sequelize";
import index from "../config";

// library
import jwt from "jsonwebtoken";
import bcrypt from "bcryptjs";

import { User } from "../models";
import index from "../config";
import constant from "../library/constant";
import isEmail from "validator/lib/isEmail";

// models
import { User } from "../models";

/**
* @회원가입
* @route POST /auth/signup
Expand All @@ -33,8 +33,7 @@ const postSignupService = async ({ email, nickname, password }) => {

// nickname 형식이 잘못되었을 때
if (
/\W/.test(nickname) ||
/_/.test(nickname) ||
!/^[-|-|a-z|A-Z|0-9|]+$/.test(nickname) ||
nickname.length < 2 ||
nickname.length > 8
) {
Expand Down Expand Up @@ -85,7 +84,7 @@ const postSignupService = async ({ email, nickname, password }) => {
},
};

const token = jwt.sign(payload, process.env.JWT_SECRET, {
const token = jwt.sign(payload, index.jwtSecret, {
expiresIn: "14d",
});
return token;
Expand Down

0 comments on commit 5b905fb

Please sign in to comment.