Toggle navigation
Toggle navigation
This project
Loading...
Sign in
공태현
/
healthcare-with-webcam
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
공태현
2022-06-06 00:57:14 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7a0f63b3d0b9a550e33283ef387840cb41c9cc59
7a0f63b3
1 parent
5e6ca7b6
Implement login page with MongoDB
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
1 deletions
server.js
views/mainPage/main.html
views/mainPage/main.js
server.js
View file @
7a0f63b
...
...
@@ -68,11 +68,12 @@ app.post('/api/users/register', (req,res) => {
// 로그인 .
app
.
post
(
'/api/users/login'
,
(
req
,
res
)
=>
{
console
.
log
(
req
.
body
)
User
.
findOne
({
name
:
req
.
body
.
name
},
(
err
,
user
)
=>
{
if
(
!
user
)
{
return
res
.
json
({
loginSuccess
:
false
,
message
:
"이름이 일치하는 사용자가 없습니다 !"
message
:
"이름이 일치하는 사용자가 없습니다 !"
,
})
}
else
if
(
req
.
body
.
password
===
user
.
password
)
{
...
...
views/mainPage/main.html
View file @
7a0f63b
...
...
@@ -5,6 +5,8 @@
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Main Page
</title>
<script
src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"
></script>
</head>
<body>
Main Page
...
...
@@ -13,5 +15,12 @@
</div>
<script
type=
"text/javascript"
src=
"./main.js"
></script>
<div>
<input
id =
"name"
type =
"text"
placeholder=
"이름"
>
<input
id =
"password"
type =
"text"
placeholder=
"비밀번호"
>
<button
type=
"submit"
id =
"button"
>
로그인
</button>
</div>
</body>
</html>
\ No newline at end of file
...
...
views/mainPage/main.js
View file @
7a0f63b
...
...
@@ -8,3 +8,35 @@ function moveSquartPage()
const
movePage
=
document
.
getElementById
(
"moveSquart"
)
movePage
.
addEventListener
(
'click'
,
moveSquartPage
);
$
(
document
).
ready
(
function
(){
$
(
'#button'
).
click
(
function
(){
let
sendName
=
$
(
'#name'
).
val
();
let
sendPassword
=
$
(
'#password'
).
val
();
let
sendData
=
{
"name"
:
sendName
,
"password"
:
sendPassword
}
$
.
ajax
({
contentType
:
"application/json; charset=utf-8"
,
type
:
'post'
,
url
:
'api/users/login'
,
data
:
JSON
.
stringify
(
sendData
),
dataType
:
'JSON'
,
success
:
function
(
datas
)
{
if
(
datas
.
loginSuccess
)
{
moveSquartPage
()
}
else
{
alert
(
datas
.
message
)
}
}
})
})
})
\ No newline at end of file
...
...
Please
register
or
login
to post a comment