mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-19 00:23:25 +02:00
allow user to create an access token to access stf api from user settings tab.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user