mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-02 07:43:11 +03:00
re-added revoke method to authentication api
closes #5530 - adds revoke api method back into code base
This commit is contained in:
parent
b8a1993f14
commit
a16be11038
@ -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…
Reference in New Issue
Block a user