mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-18 02:21:47 -05:00
Merge pull request #5532 from acburdine/revoke-fix
Add revoke method back into authentication api
This commit is contained in:
commit
74f15516fa
1 changed files with 19 additions and 0 deletions
|
@ -287,6 +287,25 @@ authentication = {
|
|||
}).then(function (result) {
|
||||
return Promise.resolve({users: [result]});
|
||||
});
|
||||
},
|
||||
|
||||
revoke: function (object) {
|
||||
var token;
|
||||
|
||||
if (object.token_type_hint && object.token_type_hint === 'access_token') {
|
||||
token = dataProvider.Accesstoken;
|
||||
} else if (object.token_type_hint && object.token_type_hint === 'refresh_token') {
|
||||
token = dataProvider.Refreshtoken;
|
||||
} else {
|
||||
return errors.BadRequestError('Invalid token_type_hint given.');
|
||||
}
|
||||
|
||||
return token.destroyByToken({token: object.token}).then(function () {
|
||||
return Promise.resolve({token: object.token});
|
||||
}, function () {
|
||||
// On error we still want a 200. See https://tools.ietf.org/html/rfc7009#page-5
|
||||
return Promise.resolve({token: object.token, error: 'Invalid token provided'});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue