Commit a2755d56 authored by Evgeniy Zaitsev's avatar Evgeniy Zaitsev
Browse files

v0.0.20

parent f225f785
'use strict';
const urlJoin = require('url-join');
const fetch = require('node-fetch');
function * checkSessionToken(next) {
const sessionToken = this.checkQuery('lvis_at').notEmpty().value;
......@@ -9,7 +10,7 @@ function * checkSessionToken(next) {
this.throwResponseErrorIfNeed(this.errors);
const user = yield * fetchUser.apply(this);
const user = yield * fetchUser.call(this, sessionToken);
this.throwResponseErrorIfNeed(!user, 'session token is invalid');
......@@ -20,17 +21,17 @@ function * checkSessionToken(next) {
yield next;
}
function * fetchUser() {
function * fetchUser(sessionToken) {
const url = urlJoin(
this.state.instance.auth_endpoint, 'p', this.state.project.id, 'sessions',
`${this.state.sessionToken}?service_id=${this.config.service.id}`
`${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}));
.then(user => user && Object.assign(user, {sessionToken: sessionToken}));
}
module.exports = checkSessionToken;
{
"name": "service-sdk",
"version": "0.0.19",
"version": "0.0.20",
"private": true,
"description": "Service SDK for LViS",
"keywords": [],
......
'use strict';
const fetch = require('node-fetch');
function * getProject() {
this.logger.log(__filename, 'GET', 'project');
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment