김대휘

중복 가입 체크

# Do-gether
----------
Sharing your TODO-LIST with others!
Sharing your TODO-LIST with others!<br>
Do-gether은 투두리스트를 다른사람들과 공유할 수 있도록 도와주는 동기부여 서비스입니다.
## HOW TO USE
----------------
You can come here and use DO-GETHER.
[`http://wwww.dogether.tk:3000`](http://wwww.dogether.tk:3000)
You can come here and use DO-GETHER.<br>
[`http://wwww.dogether.tk`](http://wwww.dogether.tk)
![main](/uploads/0b44105f829a49b4211d4e6adc9d2c33/main.png)
## HOW TO INSTALL
-------------
First, clone this project
### First, clone this project
`git clone http://khuhub.khu.ac.kr/2019102153/Do-gether.git`
and execute this command.
......@@ -21,22 +21,51 @@ cd client
npm install
```
Second, install yarn.
### Second, install yarn.
On Debian or Ubuntu Linux, you can install Yarn via our Debian package repository.
You will first need to configure the repository:
```sh
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
```
On Ubuntu 16.04 or below and Debian Stable,
On Ubuntu 16.04 or below and Debian Stable,<br>
you will also need to configure the NodeSource repository to get a new enough version of Node.js.
Then you can simply:
`sudo apt update && sudo apt install yarn`
Reference : [`https://yarnpkg.com/en/docs/install`](https://yarnpkg.com/en/docs/install)
Reference from [`YARN`](https://yarnpkg.com/en/docs/install)
### Third, add [database.json]
you should add `database.json` in the following format.
```sh
{
"host":"host name",
"user":"user name",
"password":"password",
"port":"port number",
"database":"table name"
}
```
### Finally, you can use DOGETHER by using `yarn dev` in `Do-gether` directory.
### Error
----------
In my case, an unknown error occurred when running `yarn dev`.<br>
So I solved it as follows.
Execute this command.
`vi Do-gether/client/node_modules/react-scripts/config/webpackDevServer.config.js`
And change the `disableHostCheck: ...` option to `disableHostCheck: true`.
![error](/uploads/be3c1c269c2ee157825f6d9e143706fc/error.png)
## LISENCE
---------
......
......@@ -14,7 +14,7 @@
"react-scripts": "^3.4.1"
},
"scripts": {
"start": "PORT=80 && react-scripts start",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
......
......@@ -17,7 +17,7 @@ const useStyles = makeStyles((theme) => ({
},
paper: {
width: "80%",
maxWidth:"25rem",
maxWidth: "25rem",
height: "28rem",
marginTop: "8rem",
marginLeft: "auto",
......@@ -55,7 +55,6 @@ const useStyles = makeStyles((theme) => ({
},
}));
export default function LandingPage(props) {
const classes = useStyles();
......@@ -69,25 +68,26 @@ export default function LandingPage(props) {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
}).then((response) => response.json())
.then(result => {
if(result.success === 'login sucessfull') {
localStorage.userName = result.username;
window.location.href = '/main';
}
});
})
.then((response) => response.json())
.then((result) => {
if (result.message === "login sucessfull") {
localStorage.userName = result.username;
window.location.href = "/main";
} else {
alert(result.message);
}
});
};
const handleLogin = () => {
if (!userID || !userPW) {
alert("All blanks must be filled. Try agian.");
}
else {
} else {
loginApi({
userID: userID,
userPW: userPW,
});
userID: userID,
userPW: userPW,
});
alert("Successfully login!");
props.history.push("/login");
}
......@@ -118,7 +118,12 @@ export default function LandingPage(props) {
setUserPW(e.target.value);
}}
/>
<Button className={classes.signin} variant="outlined" size="small" onClick={handleLogin}>
<Button
className={classes.signin}
variant="outlined"
size="small"
onClick={handleLogin}
>
Login
</Button>
<div className={classes.signup}>
......
......@@ -17,7 +17,7 @@ const useStyles = makeStyles((theme) => ({
},
paper: {
width: "80%",
maxWidth:"25rem",
maxWidth: "25rem",
height: "28rem",
marginTop: "8rem",
marginLeft: "auto",
......@@ -79,23 +79,29 @@ export default function LandingPage(props) {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
}).then((response) => response.json());
})
.then((response) => response.json())
.then((result) => {
if (result.message === "success") {
alert("Successfully registered!");
props.history.push("/login");
} else {
alert(result.message);
}
});
};
const handleSubmit = () => {
if (!userID || !nickName || !userPW || !checkPW) {
alert("All blanks must be filled. Try agian.");
}else if (matchPW === true){
alert("Passwords do not match.");
}
else {
signUpApi({
userID: userID,
userPW: userPW,
userName: nickName,
});
alert("Successfully registered!");
props.history.push("/login");
} else if (matchPW === true) {
alert("Passwords do not match.");
} else {
signUpApi({
userID: userID,
userPW: userPW,
userName: nickName,
});
}
};
......
......@@ -69,8 +69,7 @@ app.post("/api/addcard", (req, res) => {
app.put("/api/updatecard", (req, res) => {
const data = req.body;
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}";`;
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}";`;
console.log(sql);
connection.query(sql, (err, rows, fields) => {
if (err) {
......@@ -140,7 +139,7 @@ app.post("/api/login", (req, res) => {
// console.log("error ocurred", error);
res.send({
code: 400,
failed: "error ocurred",
message: "error ocurred",
});
} else {
// console.log('The solution is: ', results);
......@@ -149,24 +148,23 @@ app.post("/api/login", (req, res) => {
console.log(check);
if (check) {
req.session.userName = results[0].userName;
console.log( req.session.userName);
console.log(req.session.userName);
res.send({
code: 200,
success: "login sucessfull",
username : results[0].userName
message: "login sucessfull",
username: results[0].userName,
});
// res.redirect("/main");
} else {
res.send({
code: 204,
success: "Id and password does not match.",
message: "Id and password does not match.",
});
}
});
} else {
res.send({
code: 204,
success: "Id does not exists",
message: "Id does not exists",
});
}
}
......