Commit 7a9a45a8 authored by 우지원's avatar 우지원
Browse files

parent 122ea059
......@@ -27,6 +27,7 @@ const JoinRoom = () => {
// setLoading(true);
setError("");
const data = await roomApi.join({ userId: id, roomId: roomId });
console.log('서버연결됬나요', data)
setSuccess(true);
} catch (error) {
catchErrors(error, setError);
......@@ -38,8 +39,7 @@ const JoinRoom = () => {
if (success) {
// console.log('success', success)
alert('룸참여가 완료되었습니다!')
window.location.href=`/user/${id}`
// return <Redirect to={`/user/${id}`} />;
window.location.href=`/room/${roomId}/1`
}
return (
......
......@@ -24,40 +24,45 @@ const Signup = () => {
function handleChange(event) {
const { name, value } = event.target
setUser({ ...user, [name]: value })
// console.log('user정보', user)
}
async function handleSubmit(e) {
e.preventDefault()
console.log('회원가입')
try {
// console.log('checkPassword:',checkPassword())
// const passwordMatch = checkPassword()
if (checkPassword()) {
const data = await userApi.signup(user)
console.log(data)
const res = await userApi.signup(user)
console.log('서버연결됬나요', res)
console.log('회원가입')
setSuccess(true)
setError('')
}
} catch (error) {
console.log('error')
console.log('에러발생')
catchErrors(error, setError)
} finally {
// setLoading(false);
}
}
function checkPassword(event) {
const p1 = user.password
const p2 = user.checkpw
if (p1 !== p2) {
// event.preventDefault()
alert('비밀번호가 일치하지 않습니다.')
window.location.href = '/login'
return false
} else {
// alert('회원가입 되었습니다.')
// window.location.href = '/'
return true
}
}
if (success) {
alert('회원가입이 완료되었습니다!')
window.location.href = '/'
}
const { name, id, password, checkpw, phone } = user
return (
<div className="container">
......
......@@ -34,6 +34,7 @@ const joinRoom = async (req, res) => {
{ roomNumber: user_Id.roomNumber },
{ where: { id: userId } }
);
res.json(true)
} else {
return res.status(422).send("이미 참여된 방입니다.");
}
......
......@@ -39,7 +39,7 @@ const updateinfo = async (req, res) => {
};
await User.update(A, { where: { id: id } });
const user = await User.findOne({ where: { id: id } });
console.log('user:',user)
console.log('user:', user)
};
const login = async (req, res) => {
try {
......@@ -69,9 +69,9 @@ const login = async (req, res) => {
};
const signup = async (req, res) => {
try {
console.log('sign up= ', req.body)
const { name, email, password, gender, phone } = req.body
const { name, email, password, phone } = req.body
const id = Math.floor(Math.random() * (9999 - 1000) + 1000)
// console.log('id:', id)
const Id = await User.findOne({ where: { id: id } })
......@@ -80,11 +80,11 @@ const signup = async (req, res) => {
const id = Math.floor(Math.random() * (9999 - 1000) + 1000);
const Id = await User.findOne({ where: { id: id } });
}
try {
const user = await User.findOne({ where: { email: email } });
if (user)
if (user) {
return res.status(422).send(`${email} 이미 존재하는 사용자입니다.`);
} else {
if (!isLength(name, { min: 2, max: 10 })) {
return res.status(422).send("이름은 2-10자 사이입니다");
} else if (!isLength(password, { min: 6 })) {
......@@ -92,13 +92,17 @@ const signup = async (req, res) => {
} else if (!isLength(email, { min: 3, max: 10 })) {
return res.status(422).send("아이디는 3-10자 사이입니다");
}
const newUser = await User.create({
const newUser = {
id: id,
name: name,
email: email,
password: password,
phone: phone,
})
}
console.log('newUser:',newUser)
await User.create(newUser)
res.json(true)
}
} catch (error) {
console.log(error);
return res.status(500).send("회원가입 중 에러");
......
......@@ -27,7 +27,7 @@ sequelize
id: "1234567abc",
name: "room",
owner: 8888,
member: [8888,9999],
member: [8888],
profileimg: "ef0930f6be18ce73380d952337a6de1f",
});
......
......@@ -24,7 +24,7 @@ const RoomModel = (sequelize) => {
},
channel: {
type: DataTypes.ARRAY(DataTypes.JSON),
defaultValue: [{'회의':""}],
defaultValue: [{"회의": ["지원", "재연"]}, {"사담": ["지원", "재연", "서연"]}],
},
},
{ timestamps: true }
......
......@@ -18,9 +18,6 @@ const UserModel = (sequelize) => {
password: {
type: DataTypes.STRING,
},
checkpw:{
type: DataTypes.STRING,
},
phone: {
type: DataTypes.STRING,
},
......
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