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

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