2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00

Updated frame.context to use req.api_key_id (#9965)

* Added api_key_id to frame.context

refs #9865

This is to allow controllers to check permissions using api_key_id data.

* Removed client and client_id from frame.context

refs #9865

This is unused as we only support oauth on v0.1 API.
This commit is contained in:
Fabien O'Carroll 2018-10-09 18:28:38 +07:00 committed by GitHub
parent 23e9a02ff1
commit 1b9aa2546f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 6 deletions

View file

@ -14,9 +14,8 @@ const http = (apiImpl) => {
params: req.params,
user: req.user,
context: {
user: ((req.user && req.user.id) || (req.user && models.User.isExternalUser(req.user.id))) ? req.user.id : null,
client: (req.client && req.client.slug) ? req.client.slug : null,
client_id: (req.client && req.client.id) ? req.client.id : null
api_key_id: (req.api_key && req.api_key.id) ? req.api_key.id : null,
user: ((req.user && req.user.id) || (req.user && models.User.isExternalUser(req.user.id))) ? req.user.id : null
}
});

View file

@ -45,9 +45,8 @@ describe('Unit: api/shared/http', function () {
apiImpl.args[0][0].data.should.eql({a: 'a'});
apiImpl.args[0][0].options.should.eql({
context: {
user: null,
client: null,
client_id: null
api_key_id: null,
user: null
}
});
});