김대휘

중복 가입 체크

1 # Do-gether 1 # Do-gether
2 ---------- 2 ----------
3 -Sharing your TODO-LIST with others! 3 +Sharing your TODO-LIST with others!<br>
4 +Do-gether은 투두리스트를 다른사람들과 공유할 수 있도록 도와주는 동기부여 서비스입니다.
4 5
5 ## HOW TO USE 6 ## HOW TO USE
6 ---------------- 7 ----------------
7 -You can come here and use DO-GETHER. 8 +You can come here and use DO-GETHER.<br>
8 -[`http://wwww.dogether.tk:3000`](http://wwww.dogether.tk:3000) 9 +[`http://wwww.dogether.tk`](http://wwww.dogether.tk)
9 ![main](/uploads/0b44105f829a49b4211d4e6adc9d2c33/main.png) 10 ![main](/uploads/0b44105f829a49b4211d4e6adc9d2c33/main.png)
10 11
11 ## HOW TO INSTALL 12 ## HOW TO INSTALL
12 ------------- 13 -------------
13 -First, clone this project 14 +### First, clone this project
14 -
15 `git clone http://khuhub.khu.ac.kr/2019102153/Do-gether.git` 15 `git clone http://khuhub.khu.ac.kr/2019102153/Do-gether.git`
16 16
17 and execute this command. 17 and execute this command.
...@@ -21,22 +21,51 @@ cd client ...@@ -21,22 +21,51 @@ cd client
21 npm install 21 npm install
22 ``` 22 ```
23 23
24 -Second, install yarn.
25 24
25 +### Second, install yarn.
26 On Debian or Ubuntu Linux, you can install Yarn via our Debian package repository. 26 On Debian or Ubuntu Linux, you can install Yarn via our Debian package repository.
27 +
27 You will first need to configure the repository: 28 You will first need to configure the repository:
28 ```sh 29 ```sh
29 curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - 30 curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
30 echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list 31 echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
31 ``` 32 ```
32 33
33 -On Ubuntu 16.04 or below and Debian Stable, 34 +On Ubuntu 16.04 or below and Debian Stable,<br>
34 you will also need to configure the NodeSource repository to get a new enough version of Node.js. 35 you will also need to configure the NodeSource repository to get a new enough version of Node.js.
35 36
36 Then you can simply: 37 Then you can simply:
37 `sudo apt update && sudo apt install yarn` 38 `sudo apt update && sudo apt install yarn`
38 39
39 -Reference : [`https://yarnpkg.com/en/docs/install`](https://yarnpkg.com/en/docs/install) 40 +Reference from [`YARN`](https://yarnpkg.com/en/docs/install)
41 +
42 +
43 +### Third, add [database.json]
44 +you should add `database.json` in the following format.
45 +```sh
46 +{
47 + "host":"host name",
48 + "user":"user name",
49 + "password":"password",
50 + "port":"port number",
51 + "database":"table name"
52 +}
53 +```
54 +
55 +
56 +### Finally, you can use DOGETHER by using `yarn dev` in `Do-gether` directory.
57 +
58 +
59 +### Error
60 +----------
61 +In my case, an unknown error occurred when running `yarn dev`.<br>
62 +So I solved it as follows.
63 +
64 +Execute this command.
65 +`vi Do-gether/client/node_modules/react-scripts/config/webpackDevServer.config.js`
66 +
67 +And change the `disableHostCheck: ...` option to `disableHostCheck: true`.
68 +![error](/uploads/be3c1c269c2ee157825f6d9e143706fc/error.png)
40 69
41 ## LISENCE 70 ## LISENCE
42 --------- 71 ---------
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 "react-scripts": "^3.4.1" 14 "react-scripts": "^3.4.1"
15 }, 15 },
16 "scripts": { 16 "scripts": {
17 - "start": "PORT=80 && react-scripts start", 17 + "start": "react-scripts start",
18 "build": "react-scripts build", 18 "build": "react-scripts build",
19 "test": "react-scripts test", 19 "test": "react-scripts test",
20 "eject": "react-scripts eject" 20 "eject": "react-scripts eject"
......
...@@ -17,7 +17,7 @@ const useStyles = makeStyles((theme) => ({ ...@@ -17,7 +17,7 @@ const useStyles = makeStyles((theme) => ({
17 }, 17 },
18 paper: { 18 paper: {
19 width: "80%", 19 width: "80%",
20 - maxWidth:"25rem", 20 + maxWidth: "25rem",
21 height: "28rem", 21 height: "28rem",
22 marginTop: "8rem", 22 marginTop: "8rem",
23 marginLeft: "auto", 23 marginLeft: "auto",
...@@ -55,7 +55,6 @@ const useStyles = makeStyles((theme) => ({ ...@@ -55,7 +55,6 @@ const useStyles = makeStyles((theme) => ({
55 }, 55 },
56 })); 56 }));
57 57
58 -
59 export default function LandingPage(props) { 58 export default function LandingPage(props) {
60 const classes = useStyles(); 59 const classes = useStyles();
61 60
...@@ -69,25 +68,26 @@ export default function LandingPage(props) { ...@@ -69,25 +68,26 @@ export default function LandingPage(props) {
69 "Content-Type": "application/json", 68 "Content-Type": "application/json",
70 }, 69 },
71 body: JSON.stringify(data), 70 body: JSON.stringify(data),
72 - }).then((response) => response.json()) 71 + })
73 - .then(result => { 72 + .then((response) => response.json())
74 - if(result.success === 'login sucessfull') { 73 + .then((result) => {
75 - localStorage.userName = result.username; 74 + if (result.message === "login sucessfull") {
76 - window.location.href = '/main'; 75 + localStorage.userName = result.username;
77 - 76 + window.location.href = "/main";
78 - } 77 + } else {
79 - }); 78 + alert(result.message);
79 + }
80 + });
80 }; 81 };
81 - 82 +
82 const handleLogin = () => { 83 const handleLogin = () => {
83 if (!userID || !userPW) { 84 if (!userID || !userPW) {
84 alert("All blanks must be filled. Try agian."); 85 alert("All blanks must be filled. Try agian.");
85 - } 86 + } else {
86 - else {
87 loginApi({ 87 loginApi({
88 - userID: userID, 88 + userID: userID,
89 - userPW: userPW, 89 + userPW: userPW,
90 - }); 90 + });
91 alert("Successfully login!"); 91 alert("Successfully login!");
92 props.history.push("/login"); 92 props.history.push("/login");
93 } 93 }
...@@ -118,7 +118,12 @@ export default function LandingPage(props) { ...@@ -118,7 +118,12 @@ export default function LandingPage(props) {
118 setUserPW(e.target.value); 118 setUserPW(e.target.value);
119 }} 119 }}
120 /> 120 />
121 - <Button className={classes.signin} variant="outlined" size="small" onClick={handleLogin}> 121 + <Button
122 + className={classes.signin}
123 + variant="outlined"
124 + size="small"
125 + onClick={handleLogin}
126 + >
122 Login 127 Login
123 </Button> 128 </Button>
124 <div className={classes.signup}> 129 <div className={classes.signup}>
......
...@@ -17,7 +17,7 @@ const useStyles = makeStyles((theme) => ({ ...@@ -17,7 +17,7 @@ const useStyles = makeStyles((theme) => ({
17 }, 17 },
18 paper: { 18 paper: {
19 width: "80%", 19 width: "80%",
20 - maxWidth:"25rem", 20 + maxWidth: "25rem",
21 height: "28rem", 21 height: "28rem",
22 marginTop: "8rem", 22 marginTop: "8rem",
23 marginLeft: "auto", 23 marginLeft: "auto",
...@@ -79,23 +79,29 @@ export default function LandingPage(props) { ...@@ -79,23 +79,29 @@ export default function LandingPage(props) {
79 "Content-Type": "application/json", 79 "Content-Type": "application/json",
80 }, 80 },
81 body: JSON.stringify(data), 81 body: JSON.stringify(data),
82 - }).then((response) => response.json()); 82 + })
83 + .then((response) => response.json())
84 + .then((result) => {
85 + if (result.message === "success") {
86 + alert("Successfully registered!");
87 + props.history.push("/login");
88 + } else {
89 + alert(result.message);
90 + }
91 + });
83 }; 92 };
84 93
85 const handleSubmit = () => { 94 const handleSubmit = () => {
86 if (!userID || !nickName || !userPW || !checkPW) { 95 if (!userID || !nickName || !userPW || !checkPW) {
87 alert("All blanks must be filled. Try agian."); 96 alert("All blanks must be filled. Try agian.");
88 - }else if (matchPW === true){ 97 + } else if (matchPW === true) {
89 - alert("Passwords do not match."); 98 + alert("Passwords do not match.");
90 - } 99 + } else {
91 - else { 100 + signUpApi({
92 - signUpApi({ 101 + userID: userID,
93 - userID: userID, 102 + userPW: userPW,
94 - userPW: userPW, 103 + userName: nickName,
95 - userName: nickName, 104 + });
96 - });
97 - alert("Successfully registered!");
98 - props.history.push("/login");
99 } 105 }
100 }; 106 };
101 107
......
...@@ -69,8 +69,7 @@ app.post("/api/addcard", (req, res) => { ...@@ -69,8 +69,7 @@ app.post("/api/addcard", (req, res) => {
69 69
70 app.put("/api/updatecard", (req, res) => { 70 app.put("/api/updatecard", (req, res) => {
71 const data = req.body; 71 const data = req.body;
72 - const sql = 72 + const sql = `UPDATE CARDINFO SET title="${data.title}",todo="${data.todo}",ck="${data.ck}" WHERE name="${data.name}" AND date="${data.date}" AND time="${data.time}";`;
73 - `UPDATE CARDINFO SET title="${data.title}",todo="${data.todo}",ck="${data.ck}" WHERE name="${data.name}" AND date="${data.date}" AND time="${data.time}";`;
74 console.log(sql); 73 console.log(sql);
75 connection.query(sql, (err, rows, fields) => { 74 connection.query(sql, (err, rows, fields) => {
76 if (err) { 75 if (err) {
...@@ -140,7 +139,7 @@ app.post("/api/login", (req, res) => { ...@@ -140,7 +139,7 @@ app.post("/api/login", (req, res) => {
140 // console.log("error ocurred", error); 139 // console.log("error ocurred", error);
141 res.send({ 140 res.send({
142 code: 400, 141 code: 400,
143 - failed: "error ocurred", 142 + message: "error ocurred",
144 }); 143 });
145 } else { 144 } else {
146 // console.log('The solution is: ', results); 145 // console.log('The solution is: ', results);
...@@ -149,24 +148,23 @@ app.post("/api/login", (req, res) => { ...@@ -149,24 +148,23 @@ app.post("/api/login", (req, res) => {
149 console.log(check); 148 console.log(check);
150 if (check) { 149 if (check) {
151 req.session.userName = results[0].userName; 150 req.session.userName = results[0].userName;
152 - console.log( req.session.userName); 151 + console.log(req.session.userName);
153 res.send({ 152 res.send({
154 code: 200, 153 code: 200,
155 - success: "login sucessfull", 154 + message: "login sucessfull",
156 - username : results[0].userName 155 + username: results[0].userName,
157 }); 156 });
158 - // res.redirect("/main");
159 } else { 157 } else {
160 res.send({ 158 res.send({
161 code: 204, 159 code: 204,
162 - success: "Id and password does not match.", 160 + message: "Id and password does not match.",
163 }); 161 });
164 } 162 }
165 }); 163 });
166 } else { 164 } else {
167 res.send({ 165 res.send({
168 code: 204, 166 code: 204,
169 - success: "Id does not exists", 167 + message: "Id does not exists",
170 }); 168 });
171 } 169 }
172 } 170 }
......