Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design1
/
RIT_Project1
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
박권수
2021-05-20 01:07:08 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c6fc118be0187f4cb2e5ded6bd297909d37c5086
c6fc118b
1 parent
2fb33e5a
feat. token logic change : cookie -> token authorization cause : native app
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
22 deletions
server/src/api/auth/auth.ctrl.js
server/src/api/bottle/bottle.ctrl.js
server/src/api/hub/hub.ctrl.js
server/src/api/medicine/medicine.ctrl.js
server/src/api/auth/auth.ctrl.js
View file @
c6fc118
...
...
@@ -68,7 +68,8 @@ exports.login = async(ctx) => {
ctx
.
status
=
200
;
ctx
.
body
=
{
userId
userId
,
token
};
};
...
...
server/src/api/bottle/bottle.ctrl.js
View file @
c6fc118
...
...
@@ -7,8 +7,8 @@ const jwt = require('jsonwebtoken');
//약병 등록
exports
.
bottleConnect
=
async
(
ctx
)
=>
{
const
token
=
ctx
.
cookies
.
get
(
'access_token'
)
;
if
(
!
token
)
{
const
token
=
ctx
.
req
.
headers
.
authorization
;
if
(
!
token
||
!
token
.
length
)
{
ctx
.
status
=
401
;
return
;
}
...
...
@@ -55,8 +55,8 @@ exports.bottleConnect = async(ctx) => {
//약병 등록 해제
exports
.
bottleDisconnect
=
async
(
ctx
)
=>
{
const
token
=
ctx
.
cookies
.
get
(
'access_token'
)
;
if
(
!
token
)
{
const
token
=
ctx
.
req
.
headers
.
authorization
;
if
(
!
token
||
!
token
.
length
)
{
ctx
.
status
=
401
;
return
;
}
...
...
@@ -90,8 +90,8 @@ exports.bottleDisconnect = async(ctx) => {
//약병 정보를 조회 -> 약병에 현재 데이터를 요청한다. message : req
exports
.
lookupInfo
=
async
(
ctx
)
=>
{
const
token
=
ctx
.
cookies
.
get
(
'access_token'
)
;
if
(
!
token
)
{
const
token
=
ctx
.
req
.
headers
.
authorization
;
if
(
!
token
||
!
token
.
length
)
{
ctx
.
status
=
401
;
return
;
}
...
...
@@ -124,8 +124,8 @@ exports.lookupInfo = async(ctx) => {
//약병의 ID를 찾아서 약의 정보를 등록 : Post
exports
.
setMedicine
=
async
(
ctx
)
=>
{
const
token
=
ctx
.
cookies
.
get
(
'access_token'
)
;
if
(
!
token
)
{
const
token
=
ctx
.
req
.
headers
.
authorization
;
if
(
!
token
||
!
token
.
length
)
{
ctx
.
status
=
401
;
return
;
}
...
...
@@ -164,8 +164,8 @@ exports.setMedicine = async(ctx) => {
//로그인한 유저의 약병 리스트 가져오기
exports
.
getBottleList
=
async
(
ctx
)
=>
{
const
token
=
ctx
.
cookies
.
get
(
'access_token'
)
;
if
(
!
token
)
{
const
token
=
ctx
.
req
.
headers
.
authorization
;
if
(
!
token
||
!
token
.
length
)
{
ctx
.
status
=
401
;
return
;
}
...
...
server/src/api/hub/hub.ctrl.js
View file @
c6fc118
...
...
@@ -5,8 +5,8 @@ const DataProcess = require('../../lib/DataProcess');
const
jwt
=
require
(
'jsonwebtoken'
);
exports
.
hubConnect
=
async
(
ctx
)
=>
{
const
token
=
ctx
.
cookies
.
get
(
'access_token'
)
;
if
(
!
token
)
{
const
token
=
ctx
.
req
.
headers
.
authorization
;
if
(
!
token
||
!
token
.
length
)
{
ctx
.
status
=
401
;
return
;
}
...
...
@@ -40,15 +40,14 @@ exports.hubConnect = async (ctx) => {
};
exports
.
getHubList
=
async
(
ctx
)
=>
{
const
token
=
ctx
.
cookies
.
get
(
'access_token'
)
;
if
(
!
token
)
{
const
token
=
ctx
.
req
.
headers
.
authorization
;
if
(
!
token
||
!
token
.
length
)
{
ctx
.
status
=
401
;
return
;
}
const
{
userId
}
=
jwt
.
verify
(
token
,
process
.
env
.
JWT_SECRET
);
const
hubList
=
await
Hub
.
find
({
userId
});
console
.
log
(
hubList
)
if
(
!
hubList
||
!
hubList
.
length
)
{
ctx
.
status
=
404
;
return
;
...
...
@@ -59,8 +58,8 @@ exports.getHubList = async(ctx) => {
};
exports
.
hubDisconnect
=
async
(
ctx
)
=>
{
const
token
=
ctx
.
cookies
.
get
(
'access_token'
)
;
if
(
!
token
)
{
const
token
=
ctx
.
req
.
headers
.
authorization
;
if
(
!
token
||
!
token
.
length
)
{
ctx
.
status
=
401
;
return
;
}
...
...
server/src/api/medicine/medicine.ctrl.js
View file @
c6fc118
...
...
@@ -2,8 +2,8 @@
const
Medicine
=
require
(
'../../models/medicine'
);
exports
.
medicineSearch
=
async
(
ctx
)
=>
{
const
token
=
ctx
.
cookies
.
get
(
'access_token'
)
;
if
(
!
token
)
{
const
token
=
ctx
.
req
.
headers
.
authorization
;
if
(
!
token
||
!
token
.
length
)
{
ctx
.
status
=
401
;
return
;
}
...
...
@@ -29,8 +29,8 @@ exports.medicineSearch = async(ctx) => {
}
exports
.
medicineGet
=
async
(
ctx
)
=>
{
const
token
=
ctx
.
cookies
.
get
(
'access_token'
)
;
if
(
!
token
)
{
const
token
=
ctx
.
req
.
headers
.
authorization
;
if
(
!
token
||
!
token
.
length
)
{
ctx
.
status
=
401
;
return
;
}
...
...
Please
register
or
login
to post a comment