mirror of
https://github.com/openstf/stf
synced 2025-10-04 02:09:32 +02:00
Create seperate database table for AccessTokens to hide jwt token and tokenId from user
This commit is contained in:
parent
62413b3780
commit
9cb231391a
11 changed files with 97 additions and 71 deletions
|
@ -309,20 +309,23 @@ dbapi.loadDevice = function(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
|
||||
})
|
||||
return db.run(r.table('accessTokens').insert({
|
||||
email: email
|
||||
, id: token.id
|
||||
, title: token.title
|
||||
, 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)
|
||||
})
|
||||
return db.run(r.table('accessTokens').getAll(email, {
|
||||
index: 'email'
|
||||
}).filter({"title": title}).delete())
|
||||
}
|
||||
|
||||
dbapi.loadAccessTokens = function(email) {
|
||||
return db.run(r.table('accessTokens').getAll(email, {
|
||||
index: 'email'
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue