Commit e73fe78d authored by 우지원's avatar 우지원
Browse files

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

parents f56b2ff3 a8d320fd
...@@ -13,7 +13,7 @@ const server = http.createServer(app); ...@@ -13,7 +13,7 @@ const server = http.createServer(app);
app.use(express.json()); app.use(express.json());
app.use(express.urlencoded({ extended: true })); app.use(express.urlencoded({ extended: true }));
app.use(cookieParser()); app.use(cookieParser());
app.use('/uploads', express.static('uploads'))
app.use("/api", mainRouter); app.use("/api", mainRouter);
let receiverPCs = {}; let receiverPCs = {};
......
...@@ -24,6 +24,13 @@ ...@@ -24,6 +24,13 @@
"test": "react-scripts test", "test": "react-scripts test",
"eject": "react-scripts eject" "eject": "react-scripts eject"
}, },
"nodemonConfig": {
"ignore": [
"test/*",
"docs/*",
"client/*"
]
},
"eslintConfig": { "eslintConfig": {
"extends": [ "extends": [
"react-app", "react-app",
......
client/public/user.png

17.1 KB | W: | H:

client/public/user.png

16.3 KB | W: | H:

client/public/user.png
client/public/user.png
client/public/user.png
client/public/user.png
  • 2-up
  • Swipe
  • Onion skin
import axios from "axios";
const login = async (payload) => {
const { data } = await axios.post("/api/login", payload);
return data;
};
const signup = async (payload) => {
const { data } = await axios.post("/api/signup", payload);
return data;
};
const profileApi = { login, signup };
export default profileApi;
...@@ -15,6 +15,16 @@ const signup = async (payload) => { ...@@ -15,6 +15,16 @@ const signup = async (payload) => {
return data; return data;
}; };
const userApi = { getUser, login, signup }; const updateinfo = async (payload) => {
const { data } = await axios.put("/api/updateinfo", payload);
return data;
};
const profileimg = async (formData) => {
const { data } = await axios.put("/api/profileimg", formData);
return data;
};
const userApi = { login, signup, getUser, profileimg, updateinfo };
export default userApi; export default userApi;
...@@ -4,7 +4,6 @@ import roomApi from "../../apis/room.api"; ...@@ -4,7 +4,6 @@ import roomApi from "../../apis/room.api";
import catchErrors from "../../context/catchError"; import catchErrors from "../../context/catchError";
const userId = localStorage.getItem('user'); const userId = localStorage.getItem('user');
console.log(userId)
const INIT_ROOM = { const INIT_ROOM = {
name: '', name: '',
owner: userId, owner: userId,
...@@ -28,7 +27,6 @@ const CreateRoom = () => { ...@@ -28,7 +27,6 @@ const CreateRoom = () => {
const { name, value } = event.target const { name, value } = event.target
setRoom({ ...room, [name]: value }) setRoom({ ...room, [name]: value })
} }
console.log(room)
async function handleSubmit(e) { async function handleSubmit(e) {
e.preventDefault() e.preventDefault()
......
...@@ -4,10 +4,9 @@ import userApi from "../../apis/user.api"; ...@@ -4,10 +4,9 @@ import userApi from "../../apis/user.api";
import catchErrors from "../../context/catchError"; import catchErrors from "../../context/catchError";
const userprofile = localStorage.getItem("user"); const userprofile = localStorage.getItem("user");
console.log(userprofile)
const INIT_USER = { const INIT_USER = {
id: userprofile, id: userprofile,
name: '', email: '',
img: '', img: '',
} }
...@@ -17,7 +16,7 @@ const HomeProfile = () => { ...@@ -17,7 +16,7 @@ const HomeProfile = () => {
async function getSetUser(userID) { async function getSetUser(userID) {
try { try {
// console.log('userID', userID) // console.log('userID', userID)
const data = await userApi.getUser( userID ) const data = await userApi.getUser(userID)
// console.log(data) // console.log(data)
setUser(data) setUser(data)
// console.log(user) // console.log(user)
...@@ -31,20 +30,20 @@ const HomeProfile = () => { ...@@ -31,20 +30,20 @@ const HomeProfile = () => {
}, [userprofile]) }, [userprofile])
return ( return (
<Link to={`/profile/${user}`} className="text-decoration-none text-dark"> <Link to={`/profile/${user.id}`} className="text-decoration-none text-dark">
<form className="flex-column align-items-center justify-content-center m-2"> <form className="flex-column align-items-center justify-content-center m-2">
<div className="d-flex justify-content-center"> <div className="d-flex justify-content-center">
<img <img
// src="cherry.jpg" src={`/uploads/${user.img}`}
className="rounded-circle" className="rounded-circle"
style={{ style={{
width: "157px", width: "157px",
height: "157px", height: "157px",
}} }}
value={user.img} // value={user.img}
/> />
</div> </div>
<h1 className="d-flex justify-content-center"> {user.name} </h1> <h1 className="d-flex justify-content-center"> {user.email} </h1>
<h2 className="d-flex justify-content-center"> #{user.id} </h2> <h2 className="d-flex justify-content-center"> #{user.id} </h2>
</form> </form>
<div <div
......
...@@ -3,7 +3,6 @@ import { Link } from 'react-router-dom' ...@@ -3,7 +3,6 @@ import { Link } from 'react-router-dom'
import roomApi from '../../apis/room.api'; import roomApi from '../../apis/room.api';
import userApi from '../../apis/user.api'; import userApi from '../../apis/user.api';
const RoomSingle = () => { const RoomSingle = () => {
const [roomNum, setRoomNum] = useState('') const [roomNum, setRoomNum] = useState('')
const [room, setRoom] = useState([]) const [room, setRoom] = useState([])
......
import User from "../Room/User"; import userApi from "../../apis/user.api";
import { useEffect, useState } from "react";
const userprofile = localStorage.getItem("user");
const INIT_PROFILE = {
name: "",
email: "a",
id: "",
phone: "",
};
const Info = () => { const Info = () => {
const [profile, setProfile] = useState(INIT_PROFILE);
async function getProfile(userID) {
try {
const data = await userApi.getUser(userID);
setProfile(data);
} catch (error) {}
}
useEffect(() => {
getProfile(userprofile);
}, [userprofile]);
return ( return (
<div className="container" style={{ background: "#FCF4FF" }}> <div className="container" style={{ background: "#FCF4FF" }}>
<div <div
className="row justify-content-center my-4" className="row justify-content-center my-4"
style={{ fontSize: "25px", fontWeight: "bold" }} style={{ fontSize: "25px", fontWeight: "bold" }}
> >
CHERRY #0805 {profile.email} #{profile.id}
</div> </div>
<div className="row"> <div className="row">
<div className="col-3"></div> <div className="col-3"></div>
...@@ -15,14 +38,24 @@ const Info = () => { ...@@ -15,14 +38,24 @@ const Info = () => {
<h2 className="mb-3" style={{ fontSize: "13px", fontWeight: "bold" }}> <h2 className="mb-3" style={{ fontSize: "13px", fontWeight: "bold" }}>
이름 이름
</h2> </h2>
<h2 className="mb-4 mt-2" style={{ fontSize: "25px", fontWeight: "bold" }} >김채린</h2> <h2
className="mb-4 mt-2"
style={{ fontSize: "25px", fontWeight: "bold" }}
>
{profile.name}
</h2>
<h2 <h2
className="mb-3 mt-2" className="mb-3 mt-2"
style={{ fontSize: "13px", fontWeight: "bold" }} style={{ fontSize: "13px", fontWeight: "bold" }}
> >
전화번호 전화번호
</h2> </h2>
<h2 className="mb-3 mt-2" style={{ fontSize: "25px", fontWeight: "bold" }}>010-8628-8984</h2> <h2
className="mb-3 mt-2"
style={{ fontSize: "25px", fontWeight: "bold" }}
>
{profile.phone}
</h2>
</div> </div>
<div className="col"></div> <div className="col"></div>
</div> </div>
......
import { Link } from "react-router-dom"; import { Link, useParams } from "react-router-dom";
import React, { useState } from "react"; import React, { useEffect, useState } from "react";
import userApi from "../../apis/user.api";
const userprofile = localStorage.getItem("user");
const INIT_PROFILE = {
id: userprofile,
name:"",
email:"",
phone:"",
img: "",
};
const InfoUpdate = () => { const InfoUpdate = () => {
// const INIT_ACCOUNT={ const { id } = useParams();
// name:"",
// }
const [profile, setProfile] = useState(INIT_PROFILE);
// const [account, setAccount] = useState(INIT_ACCOUNT) async function getProfile(userID) {
try {
const data = await userApi.getUser(userID);
setProfile(data);
} catch (error) {}
}
// const handleChange = (e)=>{ useEffect(() => {
// const {name, value, files}=e.target getProfile(userprofile);
// if(files){ }, []);
// setAccount({...account,[name]:files})
// console.log('aaaaaaa')
// } else{
// setAccount({...account, [name]:value})
// }
// }
const id = 1; const handleChange = async (event) => {
const number = 1234; const { files } = event.target;
let formData = new FormData();
formData.append("img", files[0]);
formData.append("id", userprofile);
try {
const res = await userApi.profileimg(formData);
if(files){
setProfile({...profile, img:res})
}else{
setProfile()
} } catch (error) {}
};
const changeinfo = async (event) => {
const res = await userApi.updateinfo(profile)
};
const updateinfo = (event) => {
const { name, value } = event.target;
setProfile({ ...profile, [name]: value });
};
const{email,phone,name}=profile
return ( return (
<div className="container" style={{ background: "#FCF4FF" }}> <div className="container" style={{ background: "#FCF4FF" }}>
<div className="row"> <div className="row">
...@@ -43,6 +74,20 @@ const InfoUpdate = () => { ...@@ -43,6 +74,20 @@ const InfoUpdate = () => {
돌아가기 돌아가기
</button> </button>
</Link> </Link>
<Link to={`/profile/${id}`}>
<button
onClick={changeinfo}
type="button"
className="btn btn-outline-white mx-2 "
style={{
background: "#d4cafb",
fontSize: "13px",
fontWeight: "bold",
}}
>
저장
</button>
</Link>
</div> </div>
</div> </div>
...@@ -54,7 +99,7 @@ const InfoUpdate = () => { ...@@ -54,7 +99,7 @@ const InfoUpdate = () => {
style={{ position: "relative" }} style={{ position: "relative" }}
> >
<img <img
src="/cherry.jpg" src={`/uploads/${profile.img}`}
id="imgfile" id="imgfile"
className="rounded-circle mt-2" className="rounded-circle mt-2"
style={{ height: "320px", width: "320px" }} style={{ height: "320px", width: "320px" }}
...@@ -63,11 +108,10 @@ const InfoUpdate = () => { ...@@ -63,11 +108,10 @@ const InfoUpdate = () => {
className="d-flex justify-content-end" className="d-flex justify-content-end"
style={{ position: "absolute", left: "295px", top: "30px" }} style={{ position: "absolute", left: "295px", top: "30px" }}
> >
<label for="inputfile"> <label htmlFor="inputfile">
<img <img
className="rounded-circle" className="rounded-circle"
src="/infoimg.jpg" src="/infoimg.jpg"
// onChange={handleChange}
style={{ style={{
width: "50px", width: "50px",
height: "50px", height: "50px",
...@@ -76,6 +120,8 @@ const InfoUpdate = () => { ...@@ -76,6 +120,8 @@ const InfoUpdate = () => {
/> />
</label> </label>
<input <input
onChange={handleChange}
name="avatarUrl"
type="file" type="file"
accept="image/*" accept="image/*"
id="inputfile" id="inputfile"
...@@ -86,6 +132,9 @@ const InfoUpdate = () => { ...@@ -86,6 +132,9 @@ const InfoUpdate = () => {
<div className="col d-flex justify-content-center"> <div className="col d-flex justify-content-center">
<input <input
onChange={updateinfo}
name="email"
value={profile.email}
type="text" type="text"
className="form-control my-4 " className="form-control my-4 "
placeholder="사용자명 입력" placeholder="사용자명 입력"
...@@ -104,81 +153,63 @@ const InfoUpdate = () => { ...@@ -104,81 +153,63 @@ const InfoUpdate = () => {
className="justify-content-center ms-2 my-4" className="justify-content-center ms-2 my-4"
style={{ fontSize: "25px", fontWeight: "bold" }} style={{ fontSize: "25px", fontWeight: "bold" }}
> >
#{number} #{userprofile}
</div> </div>
</div> </div>
<div className="row">
<div className="col-3"></div>
<div className="col-6 my-2">
<h2
className="mb-3"
style={{ fontSize: "13px", fontWeight: "bold" }}
>
이름
</h2>
<input
onChange={updateinfo}
name="name"
value={profile.name}
type="text"
className="form-control my-3 "
placeholder="이름 입력"
style={{
background: "#fcf4ff",
borderTop: "0",
borderRight: "0",
borderLeft: "0",
borderBottom: "1",
borderColor: "#d4cafb",
height: "38px",
width: "180px",
}}
/>
<div className="d-flex justify-content-center"> <h2
<label className="mb-3 mt-2"
class="form-label me-3" style={{ fontSize: "13px", fontWeight: "bold" }}
style={{ >
outline: "none", 전화번호
fontSize: "13px", </h2>
fontWeight: "bold", <input
}} onChange={updateinfo}
> name="phone"
현재 비밀번호 value={profile.phone}
</label> type="text"
<input className="form-control my-3 "
type="password" placeholder="전화번호 입력"
class="form-control" style={{
style={{ height: "38px", width: "200px" }} background: "#fcf4ff",
/> borderTop: "0",
<button borderRight: "0",
type="button" borderLeft: "0",
className="btn btn-outline-white ms-2" borderBottom: "1",
style={{ borderColor: "#d4cafb",
background: "#d4cafb", height: "38px",
fontSize: "13px", width: "180px",
fontWeight: "bold", }}
}} />
>
수정하기
</button>
</div>
<div class="col-6">
<div class="input-group mx-2 my-3">
<div>
<label
class="form-label"
style={{ fontSize: "13px", fontWeight: "bold" }}
>
비밀번호
</label>
<input type="text" className="form-control" />
</div>
<div>
<label
className="form-label"
style={{ fontSize: "13px", fontWeight: "bold" }}
>
비밀번호 확인
</label>
<input type="text" className="form-control" />
</div>
</div>
</div>
<div className="col-6">
<div className="input-group my-3 ">
<div>
<label
className="form-label"
style={{ fontSize: "13px", fontWeight: "bold" }}
>
전화번호
</label>
<input type="text" className="form-control" />
</div>
<div>
<label
className="form-label"
style={{ fontSize: "13px", fontWeight: "bold" }}
>
전화번호 확인
</label>
<input type="text" className="form-control" />
</div>
</div> </div>
<div className="col"></div>
</div> </div>
</div> </div>
</div> </div>
......
import { Link } from "react-router-dom"; import { Link, useParams } from "react-router-dom";
import { useState, useEffect } from "react";
import userApi from "../../apis/user.api";
const userprofile = localStorage.getItem("user");
const INIT_PROFILE = {
img:"",
};
const Profile = () => { const Profile = () => {
const id = 1;
const [profile, setProfile] = useState(INIT_PROFILE);
async function getProfile(userID) {
try {
const data = await userApi.getUser(userID);
setProfile(data.img)
} catch (error) {}
}
useEffect(() => {
getProfile(userprofile);
}, [userprofile]);
const { id } = useParams();
return ( return (
<div className="container" style={{ background: "#FCF4FF" }}> <div className="container" style={{ background: "#FCF4FF" }}>
<> <>
...@@ -31,7 +55,7 @@ const Profile = () => { ...@@ -31,7 +55,7 @@ const Profile = () => {
<div className="col"> <div className="col">
<div className="d-flex justify-content-center"> <div className="d-flex justify-content-center">
<img <img
src="/cherry.jpg" src={`/uploads/${profile}`}
className="rounded-circle mt-2" className="rounded-circle mt-2"
style={{ height: "320px", width: "320px" }} style={{ height: "320px", width: "320px" }}
/> />
......
...@@ -37,7 +37,7 @@ const Signup = () => { ...@@ -37,7 +37,7 @@ 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); // console.log(user);
} }
async function handleSubmit() { async function handleSubmit() {
......
...@@ -34,7 +34,7 @@ const InvitePage = () => { ...@@ -34,7 +34,7 @@ const InvitePage = () => {
> >
{/* 방 부분 */} {/* 방 부분 */}
<p style={{ marginBottom: "0px", fontSize: "16px" }}>초대받은 </p> <p style={{ marginBottom: "0px", fontSize: "16px" }}>초대받은 </p>
{/* <img src={RoomImage} style={{ width: "90px", height: "90px" }}></img> */} <img style={{ width: "90px", height: "90px" }}></img>
<p style={{ marginBottom: "0px", fontSize: "16px" }}> <p style={{ marginBottom: "0px", fontSize: "16px" }}>
id: {/*${roomid}*/} id: {/*${roomid}*/}
</p> </p>
......
...@@ -105,9 +105,9 @@ ...@@ -105,9 +105,9 @@
browserslist "^4.14.5" browserslist "^4.14.5"
semver "^5.5.0" semver "^5.5.0"
"@babel/helper-create-class-features-plugin@^7.12.1", "@babel/helper-create-class-features-plugin@^7.12.13", "@babel/helper-create-class-features-plugin@^7.12.17": "@babel/helper-create-className-features-plugin@^7.12.1", "@babel/helper-create-className-features-plugin@^7.12.13", "@babel/helper-create-className-features-plugin@^7.12.17":
version "7.12.17" version "7.12.17"
resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.12.17.tgz#704b69c8a78d03fb1c5fcc2e7b593f8a65628944" resolved "https://registry.yarnpkg.com/@babel/helper-create-className-features-plugin/-/helper-create-className-features-plugin-7.12.17.tgz#704b69c8a78d03fb1c5fcc2e7b593f8a65628944"
integrity sha512-I/nurmTxIxHV0M+rIpfQBF1oN342+yvl2kwZUrQuOClMamHF1w5tknfZubgNOLRoA73SzBFAdFcpb4M9HwOeWQ== integrity sha512-I/nurmTxIxHV0M+rIpfQBF1oN342+yvl2kwZUrQuOClMamHF1w5tknfZubgNOLRoA73SzBFAdFcpb4M9HwOeWQ==
dependencies: dependencies:
"@babel/helper-function-name" "^7.12.13" "@babel/helper-function-name" "^7.12.13"
...@@ -287,20 +287,20 @@ ...@@ -287,20 +287,20 @@
"@babel/helper-remap-async-to-generator" "^7.12.13" "@babel/helper-remap-async-to-generator" "^7.12.13"
"@babel/plugin-syntax-async-generators" "^7.8.0" "@babel/plugin-syntax-async-generators" "^7.8.0"
"@babel/plugin-proposal-class-properties@7.12.1": "@babel/plugin-proposal-className-properties@7.12.1":
version "7.12.1" version "7.12.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.12.1.tgz#a082ff541f2a29a4821065b8add9346c0c16e5de" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-className-properties/-/plugin-proposal-className-properties-7.12.1.tgz#a082ff541f2a29a4821065b8add9346c0c16e5de"
integrity sha512-cKp3dlQsFsEs5CWKnN7BnSHOd0EOW8EKpEjkoz1pO2E5KzIDNV9Ros1b0CnmbVgAGXJubOYVBOGCT1OmJwOI7w== integrity sha512-cKp3dlQsFsEs5CWKnN7BnSHOd0EOW8EKpEjkoz1pO2E5KzIDNV9Ros1b0CnmbVgAGXJubOYVBOGCT1OmJwOI7w==
dependencies: dependencies:
"@babel/helper-create-class-features-plugin" "^7.12.1" "@babel/helper-create-className-features-plugin" "^7.12.1"
"@babel/helper-plugin-utils" "^7.10.4" "@babel/helper-plugin-utils" "^7.10.4"
"@babel/plugin-proposal-class-properties@^7.12.1", "@babel/plugin-proposal-class-properties@^7.12.13": "@babel/plugin-proposal-className-properties@^7.12.1", "@babel/plugin-proposal-className-properties@^7.12.13":
version "7.12.13" version "7.12.13"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.12.13.tgz#3d2ce350367058033c93c098e348161d6dc0d8c8" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-className-properties/-/plugin-proposal-className-properties-7.12.13.tgz#3d2ce350367058033c93c098e348161d6dc0d8c8"
integrity sha512-8SCJ0Ddrpwv4T7Gwb33EmW1V9PY5lggTO+A8WjyIwxrSHDUyBw4MtF96ifn1n8H806YlxbVCoKXbbmzD6RD+cA== integrity sha512-8SCJ0Ddrpwv4T7Gwb33EmW1V9PY5lggTO+A8WjyIwxrSHDUyBw4MtF96ifn1n8H806YlxbVCoKXbbmzD6RD+cA==
dependencies: dependencies:
"@babel/helper-create-class-features-plugin" "^7.12.13" "@babel/helper-create-className-features-plugin" "^7.12.13"
"@babel/helper-plugin-utils" "^7.12.13" "@babel/helper-plugin-utils" "^7.12.13"
"@babel/plugin-proposal-decorators@7.12.1": "@babel/plugin-proposal-decorators@7.12.1":
...@@ -308,7 +308,7 @@ ...@@ -308,7 +308,7 @@
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-decorators/-/plugin-proposal-decorators-7.12.1.tgz#59271439fed4145456c41067450543aee332d15f" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-decorators/-/plugin-proposal-decorators-7.12.1.tgz#59271439fed4145456c41067450543aee332d15f"
integrity sha512-knNIuusychgYN8fGJHONL0RbFxLGawhXOJNLBk75TniTsZZeA+wdkDuv6wp4lGwzQEKjZi6/WYtnb3udNPmQmQ== integrity sha512-knNIuusychgYN8fGJHONL0RbFxLGawhXOJNLBk75TniTsZZeA+wdkDuv6wp4lGwzQEKjZi6/WYtnb3udNPmQmQ==
dependencies: dependencies:
"@babel/helper-create-class-features-plugin" "^7.12.1" "@babel/helper-create-className-features-plugin" "^7.12.1"
"@babel/helper-plugin-utils" "^7.10.4" "@babel/helper-plugin-utils" "^7.10.4"
"@babel/plugin-syntax-decorators" "^7.12.1" "@babel/plugin-syntax-decorators" "^7.12.1"
...@@ -416,7 +416,7 @@ ...@@ -416,7 +416,7 @@
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.12.13.tgz#ea78a12554d784ecf7fc55950b752d469d9c4a71" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.12.13.tgz#ea78a12554d784ecf7fc55950b752d469d9c4a71"
integrity sha512-sV0V57uUwpauixvR7s2o75LmwJI6JECwm5oPUY5beZB1nBl2i37hc7CJGqB5G+58fur5Y6ugvl3LRONk5x34rg== integrity sha512-sV0V57uUwpauixvR7s2o75LmwJI6JECwm5oPUY5beZB1nBl2i37hc7CJGqB5G+58fur5Y6ugvl3LRONk5x34rg==
dependencies: dependencies:
"@babel/helper-create-class-features-plugin" "^7.12.13" "@babel/helper-create-className-features-plugin" "^7.12.13"
"@babel/helper-plugin-utils" "^7.12.13" "@babel/helper-plugin-utils" "^7.12.13"
"@babel/plugin-proposal-unicode-property-regex@^7.12.1", "@babel/plugin-proposal-unicode-property-regex@^7.12.13", "@babel/plugin-proposal-unicode-property-regex@^7.4.4": "@babel/plugin-proposal-unicode-property-regex@^7.12.1", "@babel/plugin-proposal-unicode-property-regex@^7.12.13", "@babel/plugin-proposal-unicode-property-regex@^7.4.4":
...@@ -441,9 +441,9 @@ ...@@ -441,9 +441,9 @@
dependencies: dependencies:
"@babel/helper-plugin-utils" "^7.8.0" "@babel/helper-plugin-utils" "^7.8.0"
"@babel/plugin-syntax-class-properties@^7.12.1", "@babel/plugin-syntax-class-properties@^7.12.13", "@babel/plugin-syntax-class-properties@^7.8.3": "@babel/plugin-syntax-className-properties@^7.12.1", "@babel/plugin-syntax-className-properties@^7.12.13", "@babel/plugin-syntax-className-properties@^7.8.3":
version "7.12.13" version "7.12.13"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz#b5c987274c4a3a82b89714796931a6b53544ae10" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-className-properties/-/plugin-syntax-className-properties-7.12.13.tgz#b5c987274c4a3a82b89714796931a6b53544ae10"
integrity sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA== integrity sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==
dependencies: dependencies:
"@babel/helper-plugin-utils" "^7.12.13" "@babel/helper-plugin-utils" "^7.12.13"
...@@ -583,9 +583,9 @@ ...@@ -583,9 +583,9 @@
dependencies: dependencies:
"@babel/helper-plugin-utils" "^7.12.13" "@babel/helper-plugin-utils" "^7.12.13"
"@babel/plugin-transform-classes@^7.12.1", "@babel/plugin-transform-classes@^7.12.13": "@babel/plugin-transform-classNamees@^7.12.1", "@babel/plugin-transform-classNamees@^7.12.13":
version "7.12.13" version "7.12.13"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.12.13.tgz#9728edc1838b5d62fc93ad830bd523b1fcb0e1f6" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classNamees/-/plugin-transform-classNamees-7.12.13.tgz#9728edc1838b5d62fc93ad830bd523b1fcb0e1f6"
integrity sha512-cqZlMlhCC1rVnxE5ZGMtIb896ijL90xppMiuWXcwcOAuFczynpd3KYemb91XFFPi3wJSe/OcrX9lXoowatkkxA== integrity sha512-cqZlMlhCC1rVnxE5ZGMtIb896ijL90xppMiuWXcwcOAuFczynpd3KYemb91XFFPi3wJSe/OcrX9lXoowatkkxA==
dependencies: dependencies:
"@babel/helper-annotate-as-pure" "^7.12.13" "@babel/helper-annotate-as-pure" "^7.12.13"
...@@ -870,7 +870,7 @@ ...@@ -870,7 +870,7 @@
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.12.17.tgz#4aa6a5041888dd2e5d316ec39212b0cf855211bb" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.12.17.tgz#4aa6a5041888dd2e5d316ec39212b0cf855211bb"
integrity sha512-1bIYwnhRoetxkFonuZRtDZPFEjl1l5r+3ITkxLC3mlMaFja+GQFo94b/WHEPjqWLU9Bc+W4oFZbvCGe9eYMu1g== integrity sha512-1bIYwnhRoetxkFonuZRtDZPFEjl1l5r+3ITkxLC3mlMaFja+GQFo94b/WHEPjqWLU9Bc+W4oFZbvCGe9eYMu1g==
dependencies: dependencies:
"@babel/helper-create-class-features-plugin" "^7.12.17" "@babel/helper-create-className-features-plugin" "^7.12.17"
"@babel/helper-plugin-utils" "^7.12.13" "@babel/helper-plugin-utils" "^7.12.13"
"@babel/plugin-syntax-typescript" "^7.12.13" "@babel/plugin-syntax-typescript" "^7.12.13"
...@@ -900,7 +900,7 @@ ...@@ -900,7 +900,7 @@
"@babel/helper-plugin-utils" "^7.10.4" "@babel/helper-plugin-utils" "^7.10.4"
"@babel/helper-validator-option" "^7.12.1" "@babel/helper-validator-option" "^7.12.1"
"@babel/plugin-proposal-async-generator-functions" "^7.12.1" "@babel/plugin-proposal-async-generator-functions" "^7.12.1"
"@babel/plugin-proposal-class-properties" "^7.12.1" "@babel/plugin-proposal-className-properties" "^7.12.1"
"@babel/plugin-proposal-dynamic-import" "^7.12.1" "@babel/plugin-proposal-dynamic-import" "^7.12.1"
"@babel/plugin-proposal-export-namespace-from" "^7.12.1" "@babel/plugin-proposal-export-namespace-from" "^7.12.1"
"@babel/plugin-proposal-json-strings" "^7.12.1" "@babel/plugin-proposal-json-strings" "^7.12.1"
...@@ -913,7 +913,7 @@ ...@@ -913,7 +913,7 @@
"@babel/plugin-proposal-private-methods" "^7.12.1" "@babel/plugin-proposal-private-methods" "^7.12.1"
"@babel/plugin-proposal-unicode-property-regex" "^7.12.1" "@babel/plugin-proposal-unicode-property-regex" "^7.12.1"
"@babel/plugin-syntax-async-generators" "^7.8.0" "@babel/plugin-syntax-async-generators" "^7.8.0"
"@babel/plugin-syntax-class-properties" "^7.12.1" "@babel/plugin-syntax-className-properties" "^7.12.1"
"@babel/plugin-syntax-dynamic-import" "^7.8.0" "@babel/plugin-syntax-dynamic-import" "^7.8.0"
"@babel/plugin-syntax-export-namespace-from" "^7.8.3" "@babel/plugin-syntax-export-namespace-from" "^7.8.3"
"@babel/plugin-syntax-json-strings" "^7.8.0" "@babel/plugin-syntax-json-strings" "^7.8.0"
...@@ -928,7 +928,7 @@ ...@@ -928,7 +928,7 @@
"@babel/plugin-transform-async-to-generator" "^7.12.1" "@babel/plugin-transform-async-to-generator" "^7.12.1"
"@babel/plugin-transform-block-scoped-functions" "^7.12.1" "@babel/plugin-transform-block-scoped-functions" "^7.12.1"
"@babel/plugin-transform-block-scoping" "^7.12.1" "@babel/plugin-transform-block-scoping" "^7.12.1"
"@babel/plugin-transform-classes" "^7.12.1" "@babel/plugin-transform-classNamees" "^7.12.1"
"@babel/plugin-transform-computed-properties" "^7.12.1" "@babel/plugin-transform-computed-properties" "^7.12.1"
"@babel/plugin-transform-destructuring" "^7.12.1" "@babel/plugin-transform-destructuring" "^7.12.1"
"@babel/plugin-transform-dotall-regex" "^7.12.1" "@babel/plugin-transform-dotall-regex" "^7.12.1"
...@@ -972,7 +972,7 @@ ...@@ -972,7 +972,7 @@
"@babel/helper-plugin-utils" "^7.12.13" "@babel/helper-plugin-utils" "^7.12.13"
"@babel/helper-validator-option" "^7.12.17" "@babel/helper-validator-option" "^7.12.17"
"@babel/plugin-proposal-async-generator-functions" "^7.12.13" "@babel/plugin-proposal-async-generator-functions" "^7.12.13"
"@babel/plugin-proposal-class-properties" "^7.12.13" "@babel/plugin-proposal-className-properties" "^7.12.13"
"@babel/plugin-proposal-dynamic-import" "^7.12.17" "@babel/plugin-proposal-dynamic-import" "^7.12.17"
"@babel/plugin-proposal-export-namespace-from" "^7.12.13" "@babel/plugin-proposal-export-namespace-from" "^7.12.13"
"@babel/plugin-proposal-json-strings" "^7.12.13" "@babel/plugin-proposal-json-strings" "^7.12.13"
...@@ -985,7 +985,7 @@ ...@@ -985,7 +985,7 @@
"@babel/plugin-proposal-private-methods" "^7.12.13" "@babel/plugin-proposal-private-methods" "^7.12.13"
"@babel/plugin-proposal-unicode-property-regex" "^7.12.13" "@babel/plugin-proposal-unicode-property-regex" "^7.12.13"
"@babel/plugin-syntax-async-generators" "^7.8.0" "@babel/plugin-syntax-async-generators" "^7.8.0"
"@babel/plugin-syntax-class-properties" "^7.12.13" "@babel/plugin-syntax-className-properties" "^7.12.13"
"@babel/plugin-syntax-dynamic-import" "^7.8.0" "@babel/plugin-syntax-dynamic-import" "^7.8.0"
"@babel/plugin-syntax-export-namespace-from" "^7.8.3" "@babel/plugin-syntax-export-namespace-from" "^7.8.3"
"@babel/plugin-syntax-json-strings" "^7.8.0" "@babel/plugin-syntax-json-strings" "^7.8.0"
...@@ -1000,7 +1000,7 @@ ...@@ -1000,7 +1000,7 @@
"@babel/plugin-transform-async-to-generator" "^7.12.13" "@babel/plugin-transform-async-to-generator" "^7.12.13"
"@babel/plugin-transform-block-scoped-functions" "^7.12.13" "@babel/plugin-transform-block-scoped-functions" "^7.12.13"
"@babel/plugin-transform-block-scoping" "^7.12.13" "@babel/plugin-transform-block-scoping" "^7.12.13"
"@babel/plugin-transform-classes" "^7.12.13" "@babel/plugin-transform-classNamees" "^7.12.13"
"@babel/plugin-transform-computed-properties" "^7.12.13" "@babel/plugin-transform-computed-properties" "^7.12.13"
"@babel/plugin-transform-destructuring" "^7.12.13" "@babel/plugin-transform-destructuring" "^7.12.13"
"@babel/plugin-transform-dotall-regex" "^7.12.13" "@babel/plugin-transform-dotall-regex" "^7.12.13"
...@@ -2610,7 +2610,7 @@ babel-preset-current-node-syntax@^1.0.0: ...@@ -2610,7 +2610,7 @@ babel-preset-current-node-syntax@^1.0.0:
dependencies: dependencies:
"@babel/plugin-syntax-async-generators" "^7.8.4" "@babel/plugin-syntax-async-generators" "^7.8.4"
"@babel/plugin-syntax-bigint" "^7.8.3" "@babel/plugin-syntax-bigint" "^7.8.3"
"@babel/plugin-syntax-class-properties" "^7.8.3" "@babel/plugin-syntax-className-properties" "^7.8.3"
"@babel/plugin-syntax-import-meta" "^7.8.3" "@babel/plugin-syntax-import-meta" "^7.8.3"
"@babel/plugin-syntax-json-strings" "^7.8.3" "@babel/plugin-syntax-json-strings" "^7.8.3"
"@babel/plugin-syntax-logical-assignment-operators" "^7.8.3" "@babel/plugin-syntax-logical-assignment-operators" "^7.8.3"
...@@ -2635,7 +2635,7 @@ babel-preset-react-app@^10.0.0: ...@@ -2635,7 +2635,7 @@ babel-preset-react-app@^10.0.0:
integrity sha512-itL2z8v16khpuKutx5IH8UdCdSTuzrOhRFTEdIhveZ2i1iBKDrVE0ATa4sFVy+02GLucZNVBWtoarXBy0Msdpg== integrity sha512-itL2z8v16khpuKutx5IH8UdCdSTuzrOhRFTEdIhveZ2i1iBKDrVE0ATa4sFVy+02GLucZNVBWtoarXBy0Msdpg==
dependencies: dependencies:
"@babel/core" "7.12.3" "@babel/core" "7.12.3"
"@babel/plugin-proposal-class-properties" "7.12.1" "@babel/plugin-proposal-className-properties" "7.12.1"
"@babel/plugin-proposal-decorators" "7.12.1" "@babel/plugin-proposal-decorators" "7.12.1"
"@babel/plugin-proposal-nullish-coalescing-operator" "7.12.1" "@babel/plugin-proposal-nullish-coalescing-operator" "7.12.1"
"@babel/plugin-proposal-numeric-separator" "7.12.1" "@babel/plugin-proposal-numeric-separator" "7.12.1"
...@@ -2679,7 +2679,7 @@ base@^0.11.1: ...@@ -2679,7 +2679,7 @@ base@^0.11.1:
integrity sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg== integrity sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==
dependencies: dependencies:
cache-base "^1.0.1" cache-base "^1.0.1"
class-utils "^0.3.5" className-utils "^0.3.5"
component-emitter "^1.2.1" component-emitter "^1.2.1"
define-property "^1.0.0" define-property "^1.0.0"
isobject "^3.0.1" isobject "^3.0.1"
...@@ -3205,9 +3205,9 @@ cjs-module-lexer@^0.6.0: ...@@ -3205,9 +3205,9 @@ cjs-module-lexer@^0.6.0:
resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-0.6.0.tgz#4186fcca0eae175970aee870b9fe2d6cf8d5655f" resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-0.6.0.tgz#4186fcca0eae175970aee870b9fe2d6cf8d5655f"
integrity sha512-uc2Vix1frTfnuzxxu1Hp4ktSvM3QaI4oXl4ZUqL1wjTu/BGki9TrCWoqLTg/drR1KwAEarXuRFCG2Svr1GxPFw== integrity sha512-uc2Vix1frTfnuzxxu1Hp4ktSvM3QaI4oXl4ZUqL1wjTu/BGki9TrCWoqLTg/drR1KwAEarXuRFCG2Svr1GxPFw==
class-utils@^0.3.5: className-utils@^0.3.5:
version "0.3.6" version "0.3.6"
resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463" resolved "https://registry.yarnpkg.com/className-utils/-/className-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463"
integrity sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg== integrity sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==
dependencies: dependencies:
arr-union "^3.1.0" arr-union "^3.1.0"
...@@ -4716,7 +4716,7 @@ expand-brackets@^2.1.4: ...@@ -4716,7 +4716,7 @@ expand-brackets@^2.1.4:
debug "^2.3.3" debug "^2.3.3"
define-property "^0.2.5" define-property "^0.2.5"
extend-shallow "^2.0.1" extend-shallow "^2.0.1"
posix-character-classes "^0.1.0" posix-character-classNamees "^0.1.0"
regex-not "^1.0.0" regex-not "^1.0.0"
snapdragon "^0.8.1" snapdragon "^0.8.1"
to-regex "^3.0.1" to-regex "^3.0.1"
...@@ -7991,9 +7991,9 @@ portfinder@^1.0.26: ...@@ -7991,9 +7991,9 @@ portfinder@^1.0.26:
debug "^3.1.1" debug "^3.1.1"
mkdirp "^0.5.5" mkdirp "^0.5.5"
posix-character-classes@^0.1.0: posix-character-classNamees@^0.1.0:
version "0.1.1" version "0.1.1"
resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" resolved "https://registry.yarnpkg.com/posix-character-classNamees/-/posix-character-classNamees-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs= integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=
postcss-attribute-case-insensitive@^4.0.1: postcss-attribute-case-insensitive@^4.0.1:
...@@ -8104,9 +8104,9 @@ postcss-custom-selectors@^5.1.2: ...@@ -8104,9 +8104,9 @@ postcss-custom-selectors@^5.1.2:
postcss "^7.0.2" postcss "^7.0.2"
postcss-selector-parser "^5.0.0-rc.3" postcss-selector-parser "^5.0.0-rc.3"
postcss-dir-pseudo-class@^5.0.0: postcss-dir-pseudo-className@^5.0.0:
version "5.0.0" version "5.0.0"
resolved "https://registry.yarnpkg.com/postcss-dir-pseudo-class/-/postcss-dir-pseudo-class-5.0.0.tgz#6e3a4177d0edb3abcc85fdb6fbb1c26dabaeaba2" resolved "https://registry.yarnpkg.com/postcss-dir-pseudo-className/-/postcss-dir-pseudo-className-5.0.0.tgz#6e3a4177d0edb3abcc85fdb6fbb1c26dabaeaba2"
integrity sha512-3pm4oq8HYWMZePJY+5ANriPs3P07q+LW6FAdTlkFH2XqDdP4HeeJYMOzn0HYLhRSjBO3fhiqSwwU9xEULSrPgw== integrity sha512-3pm4oq8HYWMZePJY+5ANriPs3P07q+LW6FAdTlkFH2XqDdP4HeeJYMOzn0HYLhRSjBO3fhiqSwwU9xEULSrPgw==
dependencies: dependencies:
postcss "^7.0.2" postcss "^7.0.2"
...@@ -8495,7 +8495,7 @@ postcss-preset-env@6.7.0: ...@@ -8495,7 +8495,7 @@ postcss-preset-env@6.7.0:
postcss-custom-media "^7.0.8" postcss-custom-media "^7.0.8"
postcss-custom-properties "^8.0.11" postcss-custom-properties "^8.0.11"
postcss-custom-selectors "^5.1.2" postcss-custom-selectors "^5.1.2"
postcss-dir-pseudo-class "^5.0.0" postcss-dir-pseudo-className "^5.0.0"
postcss-double-position-gradients "^1.0.0" postcss-double-position-gradients "^1.0.0"
postcss-env-function "^2.0.2" postcss-env-function "^2.0.2"
postcss-focus-visible "^4.0.0" postcss-focus-visible "^4.0.0"
...@@ -8511,14 +8511,14 @@ postcss-preset-env@6.7.0: ...@@ -8511,14 +8511,14 @@ postcss-preset-env@6.7.0:
postcss-overflow-shorthand "^2.0.0" postcss-overflow-shorthand "^2.0.0"
postcss-page-break "^2.0.0" postcss-page-break "^2.0.0"
postcss-place "^4.0.1" postcss-place "^4.0.1"
postcss-pseudo-class-any-link "^6.0.0" postcss-pseudo-className-any-link "^6.0.0"
postcss-replace-overflow-wrap "^3.0.0" postcss-replace-overflow-wrap "^3.0.0"
postcss-selector-matches "^4.0.0" postcss-selector-matches "^4.0.0"
postcss-selector-not "^4.0.0" postcss-selector-not "^4.0.0"
postcss-pseudo-class-any-link@^6.0.0: postcss-pseudo-className-any-link@^6.0.0:
version "6.0.0" version "6.0.0"
resolved "https://registry.yarnpkg.com/postcss-pseudo-class-any-link/-/postcss-pseudo-class-any-link-6.0.0.tgz#2ed3eed393b3702879dec4a87032b210daeb04d1" resolved "https://registry.yarnpkg.com/postcss-pseudo-className-any-link/-/postcss-pseudo-className-any-link-6.0.0.tgz#2ed3eed393b3702879dec4a87032b210daeb04d1"
integrity sha512-lgXW9sYJdLqtmw23otOzrtbDXofUdfYzNm4PIpNE322/swES3VU9XlXHeJS46zT2onFO7V1QFdD4Q9LiZj8mew== integrity sha512-lgXW9sYJdLqtmw23otOzrtbDXofUdfYzNm4PIpNE322/swES3VU9XlXHeJS46zT2onFO7V1QFdD4Q9LiZj8mew==
dependencies: dependencies:
postcss "^7.0.2" postcss "^7.0.2"
......
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 isLength from "validator/lib/isLength.js";
import bcrypt from "bcryptjs";
const multer = require("multer");
const uploadimg = multer({ dest: "uploads/" });
const imgUpload = uploadimg.fields([{ name: "img", maxCount: 1 }]);
const update = async (req, res) => {
try {
console.log("id:", req.body.id);
const id = req.body.id;
const avatar = req.files["img"][0];
const img = avatar.filename;
console.log(img);
await User.update({ img: img }, { where: { id: id } });
res.json(img);
} catch (error) {
console.log(error);
res.status(500).send("이미지 업데이트 실패");
}
};
const getUser = async (req, res) => { const getUser = async (req, res) => {
// console.log('req.params:',req.params)
const user = await User.findOne({ where: { id: req.params.id } }); const user = await User.findOne({ where: { id: req.params.id } });
// console.log('user:',user)
res.json(user) res.json(user)
}; };
const updateinfo = async (req, res) => {
console.log(req.body);
const { id, name, email, phone, img } = req.body;
console.log("id:", id);
const A = {
name: name,
email: email,
phone: phone,
img: img,
};
await User.update(A, { where: { id: id } });
const user = await User.findOne({ where: { id: id } });
console.log('user:',user)
};
const login = async (req, res) => { const login = async (req, res) => {
try { try {
// console.log('login= ', req.body)
const { email, password } = req.body const { email, password } = req.body
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 { } else {
const passworMatch = await user.comparePassword(password) const passworMatch = await user.comparePassword(password);
if (passworMatch) { if (passworMatch) {
const token = jwt.sign({ userID: user.id }, config.jwtSecret, { const token = jwt.sign({ userID: user.id }, config.jwtSecret, {
expiresIn: config.jwtExpires, expiresIn: config.jwtExpires,
}) });
res.cookie(config.cookieName, token, { res.cookie(config.cookieName, token, {
path: '/', path: "/",
httpOnly: true, httpOnly: true,
secure: true, secure: true,
}) });
res.json(user) res.json(user);
} else { } else {
res.status(401).send('비밀번호가 일치하지 않습니다.') res.status(401).send("비밀번호가 일치하지 않습니다.");
} }
} }
} catch (error) { } catch (error) {
// console.log(error)
return res.status(500).send('로그인 중 에러') return res.status(500).send('로그인 중 에러')
} }
} };
const signup = async (req, res) => { const signup = async (req, res) => {
try { try {
...@@ -49,20 +77,20 @@ const signup = async (req, res) => { ...@@ -49,20 +77,20 @@ const signup = async (req, res) => {
const Id = await User.findOne({ where: { id: id } }) const Id = await User.findOne({ where: { id: id } })
// console.log('Id 중복확인:', Id) // console.log('Id 중복확인:', Id)
while (Id) { while (Id) {
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 } });
} }
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} 이미 존재하는 사용자입니다.`);
if (!isLength(name, { min: 3, max: 10 })) { if (!isLength(name, { min: 3, max: 10 })) {
return res.status(422).send('이름은 3-10자 사이입니다') return res.status(422).send("이름은 3-10자 사이입니다");
} else if (!isLength(password, { min: 6 })) { } else if (!isLength(password, { min: 6 })) {
return res.status(422).send('비밀번호는 6자이상 입니다') return res.status(422).send("비밀번호는 6자이상 입니다");
} 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 = await User.create({
id: id, id: id,
...@@ -73,19 +101,22 @@ const signup = async (req, res) => { ...@@ -73,19 +101,22 @@ const signup = async (req, res) => {
phone: phone, phone: phone,
}) })
} catch (error) { } catch (error) {
console.log(error) console.log(error);
return res.status(500).send('회원가입 중 에러') return res.status(500).send("회원가입 중 에러");
} }
} };
const logout = (req, res) => { const logout = (req, res) => {
res.clearCookie('token') res.clearCookie("token");
res.send('Logout Successful') res.send("Logout Successful");
} };
export default { export default {
getUser, getUser,
login, login,
signup, signup,
logout, logout,
} imgUpload,
update,
updateinfo,
};
import bcrypt from "bcryptjs"; import bcrypt from "bcryptjs";
import { DataTypes } from "sequelize"; import { DataTypes } from "sequelize";
// import img from 'bora_it\client\public\user.png'
const UserModel = (sequelize) => { const UserModel = (sequelize) => {
const User = sequelize.define( const User = sequelize.define(
...@@ -22,11 +23,11 @@ const UserModel = (sequelize) => { ...@@ -22,11 +23,11 @@ const UserModel = (sequelize) => {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
}, },
phone: { phone: {
type: DataTypes.INTEGER, type: DataTypes.STRING,
}, },
img: { img: {
type: DataTypes.STRING, type: DataTypes.STRING,
defaultValue: "/user.png" // defaultValue: img
}, },
roomNumber: { roomNumber: {
type: DataTypes.ARRAY(DataTypes.STRING), type: DataTypes.ARRAY(DataTypes.STRING),
......
...@@ -9,7 +9,11 @@ ...@@ -9,7 +9,11 @@
"build": "tsc -p ." "build": "tsc -p ."
}, },
"nodemonConfig": { "nodemonConfig": {
"ignore": ["test/*", "docs/*", "client/*"] "ignore": [
"test/*",
"docs/*",
"client/*"
]
}, },
"repository": { "repository": {
"type": "git", "type": "git",
...@@ -27,6 +31,7 @@ ...@@ -27,6 +31,7 @@
"express": "4.17.1", "express": "4.17.1",
"http": "0.0.1-security", "http": "0.0.1-security",
"jsonwebtoken": "^8.5.1", "jsonwebtoken": "^8.5.1",
"multer": "^1.4.2",
"nanoid": "^3.1.23", "nanoid": "^3.1.23",
"nodemon": "^2.0.7", "nodemon": "^2.0.7",
"pg": "^8.6.0", "pg": "^8.6.0",
......
...@@ -7,4 +7,10 @@ router.route("/getUser/:id").get(userCtrl.getUser); ...@@ -7,4 +7,10 @@ router.route("/getUser/:id").get(userCtrl.getUser);
router.route("/login").post(userCtrl.login); router.route("/login").post(userCtrl.login);
router.route("/signup").post(userCtrl.signup); router.route("/signup").post(userCtrl.signup);
router.route("/profileimg")
.put(userCtrl.imgUpload, userCtrl.update)
router.route("/updateinfo")
.put(userCtrl.updateinfo)
router.route("/").post(userCtrl.signup);
export default router; export default router;
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