Keep naming consistent with delToken
This commit is contained in:
+6
-6
@@ -8,10 +8,10 @@ exports = module.exports = {
|
||||
del: del,
|
||||
getAll: getAll,
|
||||
getByAppIdAndType: getByAppIdAndType,
|
||||
getClientTokensByUserId: getClientTokensByUserId,
|
||||
delClientTokensByUserId: delClientTokensByUserId,
|
||||
getTokensByUserId: getTokensByUserId,
|
||||
delTokensByUserId: delTokensByUserId,
|
||||
delByAppIdAndType: delByAppIdAndType,
|
||||
addClientTokenByUserId: addClientTokenByUserId,
|
||||
addTokenByUserId: addTokenByUserId,
|
||||
delToken: delToken,
|
||||
|
||||
addDefaultClients: addDefaultClients,
|
||||
@@ -216,7 +216,7 @@ function getByAppIdAndType(appId, type, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function getClientTokensByUserId(clientId, userId, callback) {
|
||||
function getTokensByUserId(clientId, userId, callback) {
|
||||
assert.strictEqual(typeof clientId, 'string');
|
||||
assert.strictEqual(typeof userId, 'string');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
@@ -235,7 +235,7 @@ function getClientTokensByUserId(clientId, userId, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function delClientTokensByUserId(clientId, userId, callback) {
|
||||
function delTokensByUserId(clientId, userId, callback) {
|
||||
assert.strictEqual(typeof clientId, 'string');
|
||||
assert.strictEqual(typeof userId, 'string');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
@@ -275,7 +275,7 @@ function delByAppIdAndType(appId, type, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function addClientTokenByUserId(clientId, userId, expiresAt, callback) {
|
||||
function addTokenByUserId(clientId, userId, expiresAt, callback) {
|
||||
assert.strictEqual(typeof clientId, 'string');
|
||||
assert.strictEqual(typeof userId, 'string');
|
||||
assert.strictEqual(typeof expiresAt, 'number');
|
||||
|
||||
@@ -5,9 +5,9 @@ exports = module.exports = {
|
||||
get: get,
|
||||
del: del,
|
||||
getAll: getAll,
|
||||
addClientToken: addClientToken,
|
||||
getClientTokens: getClientTokens,
|
||||
delClientTokens: delClientTokens,
|
||||
addToken: addToken,
|
||||
getTokens: getTokens,
|
||||
delTokens: delTokens,
|
||||
delToken: delToken
|
||||
};
|
||||
|
||||
@@ -72,36 +72,36 @@ function getAll(req, res, next) {
|
||||
});
|
||||
}
|
||||
|
||||
function addClientToken(req, res, next) {
|
||||
function addToken(req, res, next) {
|
||||
assert.strictEqual(typeof req.params.clientId, 'string');
|
||||
assert.strictEqual(typeof req.user, 'object');
|
||||
|
||||
var expiresAt = req.query.expiresAt ? parseInt(req.query.expiresAt, 10) : Date.now() + constants.DEFAULT_TOKEN_EXPIRATION;
|
||||
if (isNaN(expiresAt) || expiresAt <= Date.now()) return next(new HttpError(400, 'expiresAt must be a timestamp in the future'));
|
||||
|
||||
clients.addClientTokenByUserId(req.params.clientId, req.user.id, expiresAt, function (error, result) {
|
||||
clients.addTokenByUserId(req.params.clientId, req.user.id, expiresAt, function (error, result) {
|
||||
if (error && error.reason === ClientsError.NOT_FOUND) return next(new HttpError(404, error.message));
|
||||
if (error) return next(new HttpError(500, error));
|
||||
next(new HttpSuccess(201, { token: result }));
|
||||
});
|
||||
}
|
||||
|
||||
function getClientTokens(req, res, next) {
|
||||
function getTokens(req, res, next) {
|
||||
assert.strictEqual(typeof req.params.clientId, 'string');
|
||||
assert.strictEqual(typeof req.user, 'object');
|
||||
|
||||
clients.getClientTokensByUserId(req.params.clientId, req.user.id, function (error, result) {
|
||||
clients.getTokensByUserId(req.params.clientId, req.user.id, function (error, result) {
|
||||
if (error && error.reason === ClientsError.NOT_FOUND) return next(new HttpError(404, error.message));
|
||||
if (error) return next(new HttpError(500, error));
|
||||
next(new HttpSuccess(200, { tokens: result }));
|
||||
});
|
||||
}
|
||||
|
||||
function delClientTokens(req, res, next) {
|
||||
function delTokens(req, res, next) {
|
||||
assert.strictEqual(typeof req.params.clientId, 'string');
|
||||
assert.strictEqual(typeof req.user, 'object');
|
||||
|
||||
clients.delClientTokensByUserId(req.params.clientId, req.user.id, function (error) {
|
||||
clients.delTokensByUserId(req.params.clientId, req.user.id, function (error) {
|
||||
if (error && error.reason === ClientsError.NOT_FOUND) return next(new HttpError(404, error.message));
|
||||
if (error) return next(new HttpError(500, error));
|
||||
next(new HttpSuccess(204));
|
||||
|
||||
+3
-3
@@ -172,9 +172,9 @@ function initializeExpressSync() {
|
||||
router.get ('/api/v1/oauth/clients/:clientId', settingsScope, routes.clients.get);
|
||||
router.post('/api/v1/oauth/clients/:clientId', settingsScope, routes.clients.add);
|
||||
router.del ('/api/v1/oauth/clients/:clientId', settingsScope, routes.clients.del);
|
||||
router.get ('/api/v1/oauth/clients/:clientId/tokens', settingsScope, routes.clients.getClientTokens);
|
||||
router.post('/api/v1/oauth/clients/:clientId/tokens', settingsScope, routes.clients.addClientToken);
|
||||
router.del ('/api/v1/oauth/clients/:clientId/tokens', settingsScope, routes.clients.delClientTokens);
|
||||
router.get ('/api/v1/oauth/clients/:clientId/tokens', settingsScope, routes.clients.getTokens);
|
||||
router.post('/api/v1/oauth/clients/:clientId/tokens', settingsScope, routes.clients.addToken);
|
||||
router.del ('/api/v1/oauth/clients/:clientId/tokens', settingsScope, routes.clients.delTokens);
|
||||
router.del ('/api/v1/oauth/clients/:clientId/tokens/:tokenId', settingsScope, routes.clients.delToken);
|
||||
|
||||
// app routes
|
||||
|
||||
Reference in New Issue
Block a user