Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
publics
service-sdk-releases
Commits
c91fc26c
Commit
c91fc26c
authored
Oct 20, 2016
by
Evgeniy Zaitsev
Browse files
v0.0.18
parent
93dff9e9
Changes
3
Hide whitespace changes
Inline
Side-by-side
middlewares/checkSessionToken.js
View file @
c91fc26c
...
...
@@ -5,9 +5,28 @@ function * checkSessionToken(next) {
this
.
throwResponseErrorIfNeed
(
this
.
errors
);
this
.
state
.
sessionToken
=
sessionToken
;
const
user
=
yield
*
fetchUser
.
apply
(
this
);
this
.
throwResponseErrorIfNeed
(
!
user
,
'
session token is invalid
'
);
this
.
logger
.
log
(
__filename
,
'
user
'
,
user
);
this
.
state
.
user
=
user
;
yield
next
;
}
function
*
fetchUser
()
{
const
url
=
urlJoin
(
this
.
state
.
instance
.
auth_endpoint
,
'
p
'
,
this
.
state
.
project
.
id
,
'
sessions
'
,
`
${
this
.
state
.
sessionToken
}
?service_id=
${
this
.
config
.
service
.
id
}
`
);
this
.
logger
.
log
(
__filename
,
'
fetch user url:
'
,
url
);
yield
fetch
(
url
)
.
then
(
res
=>
res
.
json
())
.
then
(
user
=>
Object
.
assign
(
user
,
{
sessionToken
:
this
.
state
.
sessionToken
}));
}
module
.
exports
=
checkSessionToken
;
package.json
View file @
c91fc26c
{
"name"
:
"service-sdk"
,
"version"
:
"0.0.1
7
"
,
"version"
:
"0.0.1
8
"
,
"private"
:
true
,
"description"
:
"Service SDK for LViS"
,
"keywords"
:
[],
...
...
router/tab.js
View file @
c91fc26c
...
...
@@ -10,12 +10,8 @@ function * getProject() {
return
;
}
const
user
=
yield
*
fetchUser
.
apply
(
this
);
this
.
logger
.
log
(
__filename
,
'
user
'
,
user
);
this
.
body
=
yield
this
.
config
.
projectTabCallback
(
this
.
state
.
instance
,
this
.
state
.
project
,
this
.
state
.
tabId
,
user
this
.
state
.
instance
,
this
.
state
.
project
,
this
.
state
.
tabId
,
this
.
state
.
user
);
}
...
...
@@ -26,26 +22,9 @@ function * getEvent() {
return
;
}
const
user
=
yield
*
fetchUser
.
apply
(
this
);
this
.
logger
.
log
(
__filename
,
'
user
'
,
user
);
this
.
body
=
yield
this
.
config
.
projectTabCallback
(
this
.
state
.
instance
,
this
.
state
.
project
,
this
.
state
.
eventId
,
this
.
state
.
tabId
,
user
this
.
state
.
instance
,
this
.
state
.
project
,
this
.
state
.
eventId
,
this
.
state
.
tabId
,
this
.
state
.
user
);
}
module
.
exports
=
{
getProject
,
getEvent
};
function
*
fetchUser
()
{
const
url
=
urlJoin
(
this
.
state
.
instance
.
auth_endpoint
,
'
p
'
,
this
.
state
.
project
.
id
,
'
sessions
'
,
`
${
this
.
config
.
service
.
id
}
?service_id=
${
this
.
state
.
sessionToken
}
`
);
this
.
logger
.
log
(
__filename
,
'
fetch user url:
'
,
url
);
yield
fetch
(
url
)
.
then
(
res
=>
res
.
json
())
.
then
(
user
=>
Object
.
assign
(
user
,
{
sessionToken
:
this
.
state
.
sessionToken
}));
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment