Commit c00faaf3 authored by Kim, Chaerin's avatar Kim, Chaerin
Browse files

Merge remote-tracking branch 'origin/seoyeon2' into merge

parents eaa0070d 6ddc36e4
...@@ -41,6 +41,10 @@ const Login = () => { ...@@ -41,6 +41,10 @@ const Login = () => {
return <Redirect to="/user" />; return <Redirect to="/user" />;
} }
if (success) {
alert('로그인 되었습니다')
}
const { email, password } = user; const { email, password } = user;
return ( return (
......
...@@ -51,6 +51,11 @@ const Signup = () => { ...@@ -51,6 +51,11 @@ const Signup = () => {
} }
} }
if (success) {
alert('회원가입 되었습니다.')
}
const { name, idNumber1, idNumber2, id, password, checkpw, phone } = user; const { name, idNumber1, idNumber2, id, password, checkpw, phone } = user;
return ( return (
<div className="modal-content"> <div className="modal-content">
......
import { User } from "../models/index.js"; import { User } from "../models/index.js";
import jwt from "jsonwebtoken"; import jwt from "jsonwebtoken";
import config from "../config/app.config.js"; import config from "../config/app.config.js";
import isLength from 'validator/lib/isLength.js'
import bcrypt from "bcryptjs";
const test = async (req, res) => { const test = async (req, res) => {
try { try {
...@@ -42,15 +44,32 @@ const login = async (req, res) => { ...@@ -42,15 +44,32 @@ const login = async (req, res) => {
const signup = async (req, res) => { const signup = async (req, res) => {
try { try {
console.log("sign up= ", req.body); console.log('signup= ', req.body);
const { id, name, email, password, gender, phone } = req.body; const { name, password, id } = req.body;
const user = User.create({ id, name, email, password, gender, phone }); if (!isLength(name, {min: 3, max: 10})) {
return res.status(422).send('이름은 3-10자 사이입니다')
} else if (!isLength(password, {min: 6})) {
return res.status(422).send('비밀번호는 6자 이상입니다')
} else if (!isLength(id, {min:3, max10})) {
return res.status(422).send('아이디는 3-10자 사이입니다')
}
const user = await User.scope("password").findOne({ where: email });
if (user)
return res.status(422).send(`${email} 이미 존재하는 사용자입니다/+ `);
const hash = await bcrypt.hash(password, 10)
const newUser = await new User ({
name,
password: hash,
id
}).save()
console.log(newUser)
res.json(newUser)
} catch (error) { } catch (error) {
console.log(error); console.log(error);
return res.status(500).send("회원가입 중 에러"); return res.status(500).send("회원가입 중 에러")
} }
}; }
export default { export default {
test, test,
login, login,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment