1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-06 03:50:04 +02:00

Create seperate database table for AccessTokens to hide jwt token and tokenId from user

This commit is contained in:
Vishal Banthia 2015-11-26 02:36:09 +09:00
parent 62413b3780
commit 9cb231391a
11 changed files with 97 additions and 71 deletions

View file

@ -200,6 +200,29 @@ module.exports = function(options) {
})
})
app.get('/app/api/v1/accessTokens', function(req, res) {
dbapi.loadAccessTokens(req.user.email)
.then(function(cursor) {
return Promise.promisify(cursor.toArray, cursor)()
.then(function(list) {
var titles = []
list.forEach(function(token) {
titles.push(token.title)
})
res.json({
success: true
, titles: titles
})
})
})
.catch(function(err) {
log.error('Failed to load tokens: ', err.stack)
res.json(500, {
success: false
})
})
})
server.listen(options.port)
log.info('Listening on port %d', options.port)
}