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
Seokjin
2022-05-25 11:58:22 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
719d6d545f09d9f01b3963d64af416df313e049d
719d6d54
1 parent
358f390d
[Update] Login, Register Files
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 additions
and
55 deletions
weather_briefing/server/server.js
weather_briefing/server/server.js
View file @
719d6d5
let
express
=
require
(
'express'
);
let
bodyParser
=
require
(
'body-parser'
);
let
mongoose
=
require
(
'mongoose'
);
<<<<<<<
HEAD
let
cors
=
require
(
'cors'
);
let
app
=
express
();
app
.
use
(
cors
());
=======
let
nx
,
ny
;
let
app
=
express
();
const
cors
=
require
(
'cors'
);
app
.
use
(
cors
);
>>>>>>>
origin
/
weather
let
logid
=
null
;
//const uri = 'mongodb+srv://sjieu17:tjrwls147714@cluster0.lc6pe.mongodb.net/weather_briefing?retryWrites=true&w=majority';
...
...
@@ -24,19 +17,12 @@ let db = mongoose.connect(uri, (err) => {
console
.
log
(
'Succesfully Connected!'
);
}
});
//생년월일을 인자로 추가
var
UserSchema
=
new
mongoose
.
Schema
({
name
:
String
,
id
:
String
,
<<<<<<<
HEAD
password
:
String
,
gender
:
String
=======
password
:
String
,
gender
:
String
,
//nx:String,
//ny:String
>>>>>>>
origin
/
weather
});
var
Users
=
mongoose
.
model
(
'users'
,
UserSchema
);
...
...
@@ -45,23 +31,15 @@ app.use(bodyParser.json());
app
.
use
(
bodyParser
.
urlencoded
({
limit
:
'1gb'
,
extended
:
false
}));
app
.
post
(
'/api/register'
,
(
req
,
res
)
=>
{
<<<<<<<
HEAD
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'
});
=======
Users
.
findOne
({
id
:
req
.
body
.
id
,
password
:
req
.
body
.
password
},
(
err
,
user
)
=>
{
if
(
err
)
return
res
.
status
(
500
).
json
({
message
:
'에러가 발생하였습니다.'
});
else
if
(
user
){
res
.
send
(
'이미 존재하는 사용자입니다.'
);
>>>>>>>
origin
/
weather
}
else
{
const
new_user
=
new
Users
(
req
.
body
);
<<<<<<<
HEAD
new_user
.
save
((
err
)
=>
{
if
(
err
)
return
res
.
status
(
500
).
json
({
registerSuccess
:
'-1'
});
else
return
res
.
status
(
200
).
json
({
registerSuccess
:
'1'
});
...
...
@@ -78,22 +56,6 @@ app.post('/api/login', (req, res) => {
else
if
(
user
)
{
// logid={id:user.id,password:user.password,name:user.name,gender:user.gender};
return
res
.
status
(
200
).
json
({
loginSuccess
:
true
});
=======
new_user
.
save
((
err
)
=>
{
if
(
err
)
return
res
.
status
(
500
).
json
({
message
:
'회원가입에 실패하였습니다.'
,
success
:
false
,
err
});
else
return
res
.
status
(
200
).
json
({
message
:
'회원가입이 완료되었습니다.'
,
success
:
true
});
});
}
});
});
app
.
post
(
'/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
,
address1
:
user
.
address1
,
address2
:
user
.
address2
,
address3
:
user
.
address3
};
return
res
.
status
(
200
).
json
({
message
:
'로그인 되었습니다.'
,
data
:
user
});
>>>>>>>
origin
/
weather
}
else
return
res
.
status
(
404
).
json
({
loginSuccess
:
false
});
});
...
...
@@ -103,21 +65,5 @@ app.post('/api/logout',(req,res)=>{
logid
=
null
;
res
.
send
(
'로그아웃 되었습니다.'
);
});
<<<<<<<
HEAD
=======
// const xlsx=require('xlsx');
// const excel=xlsx.readFile('location(x,y).xlsx');
// const sheet=excel.SheetNames[0];
// const first=excel.Sheets[sheet];
// const jsonData=xlsx.utils.sheet_to_json(first,{defval:""});
// jsonData.findOne({address1:logid.address1,address2:logid.address2,address3:logid.address3},(err,user)=>{
// if (err) return console.log("일치하는 주소가 없습니다.");
// else if(user){
// tmp=Object.values(user);
// nx=tmp[5];
// ny=tmp[6];
// }
// });
>>>>>>>
origin
/
weather
app
.
listen
(
4000
,
()
=>
console
.
log
(
'Server On 4000'
));
\ No newline at end of file
...
...
Please
register
or
login
to post a comment