+exports.getTokens = function (req, res, next) {
+ tokenStore.getApiTokens(function (error, result) {
+ if (error) return next(new HttpError(500, error));
+
+ next(new HttpSuccess(200, { accessTokens: result }));
+ });
+};
+
+exports.createToken = function (req, res, next) {
+ var accessToken = API_TOKEN_PREFIX + uuid();
+
+ tokenStore.set(accessToken, req.user, function (error) {
+ if (error) return next(new HttpError(500, error));
+
+ next(new HttpSuccess(201, { accessToken: accessToken }));
+ });
+};
+
+exports.delToken = function (req, res, next) {
+ tokenStore.del(req.params.token, function (error) {
+ if (error) console.error(error);
+
+ next(new HttpSuccess(200, {}));
+ });
+};
+