mirror of
https://github.com/openstf/stf
synced 2025-10-04 02:09:32 +02:00
allow user to create an access token to access stf api from user settings tab.
This commit is contained in:
parent
ddc24e5dc5
commit
62413b3780
21 changed files with 263 additions and 65 deletions
|
@ -308,4 +308,22 @@ dbapi.loadDevice = function(serial) {
|
|||
return db.run(r.table('devices').get(serial))
|
||||
}
|
||||
|
||||
dbapi.saveUserAccessToken = function(email, token) {
|
||||
return db.run(r.table('users').get(email).update({
|
||||
accessTokens: r.row('accessTokens').default([]).append({
|
||||
title: token.title
|
||||
, tokenId: token.tokenId
|
||||
, jwt: token.jwt
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
dbapi.removeUserAccessToken = function(email, title) {
|
||||
return db.run(r.table('users').get(email).update({
|
||||
accessTokens: r.row('accessTokens').default([]).filter(function(token) {
|
||||
return token('title').ne(title)
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
module.exports = dbapi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue