0
Fork 0
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:
Hannah Wolfe 2015-07-08 22:17:54 +01:00
commit 74f15516fa

View file

@ -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'});
});
}
};