Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김대휘
/
Do-gether
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김대휘
2020-06-25 10:58:55 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e4c468d63b3fb1c31dcde894849fb78019e4af9e
e4c468d6
1 parent
a3cdd4bc
회원가입 구현
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
108 additions
and
19 deletions
client/src/components/ModalControl.js
client/src/pages/LoginPage.js
client/src/pages/SignUpPage.js
package.json
server.js
yarn.lock
client/src/components/ModalControl.js
View file @
e4c468d
...
...
@@ -75,7 +75,7 @@ export default function AddButton({ handleClose }) {
const
[
title
,
setTitle
]
=
useState
(
""
);
const
[
date
,
setDate
]
=
useState
(
new
Date
());
const
[
isPublic
,
setIsPublic
]
=
useState
(
1
);
const
[
textList
,
setTextList
]
=
useState
(
new
Array
()
);
const
[
textList
,
setTextList
]
=
useState
(
[]
);
const
[
textFieldBody
,
setTextFieldBody
]
=
useState
([
<
TextField
required
label
=
"To do 1"
onChange
=
{(
e
)
=>
handleText
(
e
,
0
)}
/>
,
]);
...
...
client/src/pages/LoginPage.js
View file @
e4c468d
...
...
@@ -49,8 +49,8 @@ const useStyles = makeStyles((theme) => ({
width
:
"70%"
,
},
signup
:
{
fontSize
:
13
,
top
:
"7.9rem"
,
fontSize
:
13
,
},
}));
...
...
client/src/pages/SignUpPage.js
View file @
e4c468d
...
...
@@ -32,54 +32,96 @@ const useStyles = makeStyles((theme) => ({
},
title
:
{
width
:
"100%"
,
marginTop
:
"5rem"
,
marginTop
:
"
3.
5rem"
,
fontSize
:
40
,
textAlign
:
"center"
,
},
idInput
:
{
top
:
"3.5rem"
,
top
:
"2rem"
,
width
:
"70%"
,
},
nameItput
:
{
top
:
"3rem"
,
width
:
"70%"
,
},
pwInput
:
{
top
:
"5.5rem"
,
top
:
"4rem"
,
width
:
"70%"
,
},
pwCheck
:
{
top
:
"5rem"
,
width
:
"70%"
,
},
s
ignin
:
{
top
:
"
7.4
rem"
,
s
ubmit
:
{
top
:
"
6.5
rem"
,
width
:
"70%"
,
},
signup
:
{
login
:
{
top
:
"7rem"
,
fontSize
:
13
,
top
:
"7.9rem"
,
},
}));
export
default
function
LandingPage
()
{
export
default
function
LandingPage
(
props
)
{
const
classes
=
useStyles
();
const
[
userID
,
setUserID
]
=
useState
();
const
[
N
ickName
,
setNickName
]
=
useState
();
const
[
n
ickName
,
setNickName
]
=
useState
();
const
[
userPW
,
setUserPW
]
=
useState
();
const
[
checkPW
,
setCheckPW
]
=
useState
();
const
[
matchPW
,
setMatchPW
]
=
useState
(
false
);
const
signUpApi
=
(
data
)
=>
{
return
fetch
(
"/api/signup"
,
{
method
:
"POST"
,
headers
:
{
"Content-Type"
:
"application/json"
,
},
body
:
JSON
.
stringify
(
data
),
}).
then
((
response
)
=>
response
.
json
());
};
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"
);
}
};
return
(
<
div
className
=
{
classes
.
root
}
>
<
Paper
className
=
{
classes
.
paper
}
elevation
=
{
3
}
>
<
Grid
container
className
=
{
classes
.
grid
}
>
<
div
className
=
{
classes
.
title
}
>
SIGN
IN
<
/div
>
<
div
className
=
{
classes
.
title
}
>
SIGN
UP
<
/div
>
<
TextField
required
className
=
{
classes
.
idInput
}
label
=
"ID"
variant
=
"outlined"
size
=
"small"
onChange
=
{(
e
)
=>
{
setUserID
(
e
.
target
.
value
);
}}
/
>
<
TextField
required
className
=
{
classes
.
idIn
put
}
label
=
"
ID
"
className
=
{
classes
.
nameIt
put
}
label
=
"
NickName
"
variant
=
"outlined"
size
=
"small"
onChange
=
{(
e
)
=>
{
setNickName
(
e
.
target
.
value
);
}}
/
>
<
TextField
required
...
...
@@ -89,20 +131,42 @@ export default function LandingPage() {
autoComplete
=
"current-password"
variant
=
"outlined"
size
=
"small"
onChange
=
{(
e
)
=>
{
setUserPW
(
e
.
target
.
value
);
}}
/
>
<
TextField
required
className
=
{
classes
.
pwInput
}
label
=
"Password"
error
=
{
matchPW
}
className
=
{
classes
.
pwCheck
}
label
=
"Re-enter Password"
type
=
"password"
autoComplete
=
"current-password"
variant
=
"outlined"
size
=
"small"
onChange
=
{(
e
)
=>
{
const
value
=
e
.
target
.
value
;
setCheckPW
(
value
);
if
(
value
!==
userPW
)
{
setMatchPW
(
true
);
}
else
{
setMatchPW
(
false
);
}
}}
/
>
<
Button
className
=
{
classes
.
signin
}
variant
=
"outlined"
size
=
"small"
>
Login
<
Button
className
=
{
classes
.
submit
}
variant
=
"outlined"
size
=
"small"
onClick
=
{
handleSubmit
}
>
Submit
<
/Button
>
<
div
className
=
{
classes
.
signup
}
>
Click
here
to
SIGN
UP
<
/div
>
<
div
className
=
{
classes
.
login
}
>
<
Link
to
=
"/login"
style
=
{{
color
:
"gray"
,
textDecoration
:
"none"
}}
>
Click
here
to
return
to
the
login
page
<
/Link
>
<
/div
>
<
/Grid
>
<
/Paper
>
<
/div
>
...
...
package.json
View file @
e4c468d
...
...
@@ -7,6 +7,7 @@
"dev"
:
"concurrently --kill-others-on-fail
\"
yarn server
\"
\"
yarn client
\"
"
},
"dependencies"
:
{
"bcrypt"
:
"^5.0.0"
,
"body-parser"
:
"^1.18.3"
,
"express"
:
"^4.16.4"
,
"mysql"
:
"^2.18.1"
...
...
server.js
View file @
e4c468d
...
...
@@ -5,6 +5,9 @@ const app = express();
const
port
=
process
.
env
.
PORT
||
5000
;
const
bcrypt
=
require
(
'bcrypt'
);
const
saltRounds
=
10
;
const
data
=
fs
.
readFileSync
(
"./database.json"
);
const
conf
=
JSON
.
parse
(
data
);
const
mysql
=
require
(
"mysql"
);
...
...
@@ -47,4 +50,25 @@ app.post("/api/addcard", (req, res) => {
});
});
app
.
post
(
"/api/signup"
,
(
req
,
res
)
=>
{
const
data
=
req
.
body
;
console
.
log
(
data
);
const
sql
=
"INSERT INTO USERINFO(userID,userPW,userName) VALUES(?,?,?);"
;
const
params
=
[
data
.
userID
,
data
.
userPW
,
data
.
userName
];
connection
.
query
(
sql
,
params
,
(
err
,
rows
,
fields
)
=>
{
if
(
err
)
{
res
.
send
({
code
:
400
,
message
:
"error"
,
});
}
else
{
res
.
send
({
code
:
200
,
message
:
"success"
,
});
}
});
});
app
.
listen
(
port
,
()
=>
console
.
log
(
`Listening on port
${
port
}
`
));
...
...
yarn.lock
View file @
e4c468d
This diff is collapsed. Click to expand it.
Please
register
or
login
to post a comment