Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김건희
/
OSSW_Weather_Briefing
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김건희
2022-05-24 02:34:40 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7a0b953ddf432f2aa23fcdb5e7244c3b57432329
7a0b953d
1 parent
1a2aaae2
[Update] Register, Login Files
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
16 deletions
weather_briefing/server/server.js
weather_briefing/server/server.js
View file @
7a0b953
...
...
@@ -32,14 +32,7 @@ app.use(bodyParser.urlencoded({ limit: '1gb', extended: false }));
app
.
post
(
'/api/register'
,
(
req
,
res
)
=>
{
const
new_user
=
new
Users
(
req
.
body
);
new_user
.
save
((
err
)
=>
{
if
(
err
)
return
res
.
status
(
500
).
json
({
registerSuccess
:
false
});
else
return
res
.
status
(
200
).
json
({
registerSuccess
:
true
});
})
/*Users.findOne({ id: req.body.id, password: req.body.password }, (err, user) => {
Users
.
findOne
({
id
:
req
.
body
.
id
,
password
:
req
.
body
.
password
},
(
err
,
user
)
=>
{
if
(
err
)
return
res
.
status
(
500
).
json
({
registerSuccess
:
'-1'
});
else
if
(
user
){
res
.
json
({
registerSuccess
:
'0'
});
...
...
@@ -52,19 +45,20 @@ app.post('/api/register', (req, res) => {
else
return
res
.
status
(
200
).
json
({
registerSuccess
:
'1'
});
});
}
});
*/
});
});
app
.
post
(
'/api/login'
,
(
req
,
res
)
=>
{
Users
.
findOne
({
id
:
req
.
body
.
id
,
password
:
req
.
body
.
password
},
(
err
,
user
)
=>
{
if
(
err
)
return
res
.
status
(
500
).
json
({
message
:
'에러가 발생하였습니다.'
});
else
if
(
user
){
logid
=
{
id
:
user
.
id
,
password
:
user
.
password
,
name
:
user
.
name
,
gender
:
user
.
gender
};
return
res
.
status
(
200
).
json
({
message
:
'로그인 되었습니다.'
,
data
:
user
});
Users
.
findOne
({
id
:
req
.
body
.
id
,
password
:
req
.
body
.
password
},
(
err
,
user
)
=>
{
if
(
err
)
return
res
.
status
(
500
).
json
({
loginSuccess
:
false
});
else
if
(
user
)
{
// logid={id:user.id,password:user.password,name:user.name,gender:user.gender};
return
res
.
status
(
200
).
json
({
loginSuccess
:
true
});
}
else
return
res
.
status
(
404
).
json
({
message
:
'아이디와 비밀번호를 다시 확인해주세요.'
});
});
else
return
res
.
status
(
404
).
json
({
loginSuccess
:
false
});
});
});
app
.
post
(
'/api/logout'
,(
req
,
res
)
=>
{
...
...
Please
register
or
login
to post a comment