зеркало из https://github.com/mozilla/galaxy-api.git
Modify featured endpoints to use the user view wrappers
This commit is contained in:
Родитель
2cf70bdf6e
Коммит
dfd34aafda
|
@ -4,7 +4,7 @@ var _ = require('lodash');
|
|||
var auth = require('../../lib/auth');
|
||||
var db = require('../../db');
|
||||
var genrelib = require('../../lib/genre');
|
||||
var user = require('../../lib/user');
|
||||
var userlib = require('../../lib/user');
|
||||
|
||||
|
||||
module.exports = function(server) {
|
||||
|
@ -72,17 +72,9 @@ module.exports = function(server) {
|
|||
isRequired: false
|
||||
}
|
||||
}
|
||||
}, db.redisView(function(client, done, req, res, wrap) {
|
||||
}, userlib.userDataView(function(user, client, done, req, res, wrap) {
|
||||
var DATA = req.params;
|
||||
|
||||
// TODO: Use @aricha's plugin once it is merged to master
|
||||
var _user = DATA._user;
|
||||
var email = auth.verifySSA(_user);
|
||||
if (!email) {
|
||||
res.json(403, {error: 'bad_user'});
|
||||
return done();
|
||||
}
|
||||
|
||||
// TODO: Check for valid game. (issue #57)
|
||||
var game = DATA.game;
|
||||
if (!game) {
|
||||
|
@ -119,9 +111,7 @@ module.exports = function(server) {
|
|||
}));
|
||||
}
|
||||
|
||||
user.getUserFromEmail(client, email, db.plsNoError(res, done, function(authenticator) {
|
||||
if (!authenticator.permissions ||
|
||||
(!authenticator.permissions.admin && !authenticator.permissions.reviewer)) {
|
||||
if (!user.permissions || (!user.permissions.admin && !user.permissions.reviewer)) {
|
||||
res.json(403, {error: 'bad_permission'});
|
||||
return done();
|
||||
}
|
||||
|
@ -141,7 +131,6 @@ module.exports = function(server) {
|
|||
}));
|
||||
}));
|
||||
}));
|
||||
}));
|
||||
|
||||
// Sample usage:
|
||||
// % curl -X PUT 'http://localhost:5000/featured' -d '_user=ssa_token&game=game_slug&genres=["simulation"]'
|
||||
|
@ -166,17 +155,9 @@ module.exports = function(server) {
|
|||
isRequired: false
|
||||
}
|
||||
}
|
||||
}, db.redisView(function(client, done, req, res, wrap) {
|
||||
}, userlib.userDataView(function(user, client, done, req, res, wrap) {
|
||||
var DATA = req.params;
|
||||
|
||||
// TODO: Use @aricha's plugin once it is merged to master
|
||||
var _user = DATA._user;
|
||||
var email = auth.verifySSA(_user);
|
||||
if (!email) {
|
||||
res.json(403, {error: 'bad_user'});
|
||||
return done();
|
||||
}
|
||||
|
||||
// TODO: Check for valid game. (issue #57)
|
||||
var game = DATA.game;
|
||||
if (!game) {
|
||||
|
@ -220,9 +201,7 @@ module.exports = function(server) {
|
|||
}));
|
||||
}
|
||||
|
||||
user.getUserFromEmail(client, email, db.plsNoError(res, done, function(authenticator) {
|
||||
if (!authenticator.permissions ||
|
||||
(!authenticator.permissions.admin && !authenticator.permissions.reviewer)) {
|
||||
if (!user.permissions || (!user.permissions.admin && !user.permissions.reviewer)) {
|
||||
res.json(403, {error: 'bad_permission'});
|
||||
return done();
|
||||
}
|
||||
|
@ -241,7 +220,6 @@ module.exports = function(server) {
|
|||
});
|
||||
}));
|
||||
}));
|
||||
}));
|
||||
|
||||
// Sample usage:
|
||||
// % curl -X DELETE 'http://localhost:5000/featured' -d '_user=ssa_token&game=game_slug'
|
||||
|
@ -262,18 +240,9 @@ module.exports = function(server) {
|
|||
isRequired: true
|
||||
}
|
||||
}
|
||||
}, db.redisView(function(client, done, req, res, wrap) {
|
||||
}, userlib.userDataView(function(user, client, done, req, res, wrap) {
|
||||
var DATA = req.params;
|
||||
|
||||
// Check if the user have permission to add a featured game
|
||||
// TODO: Use @aricha's plugin once it is merged to master
|
||||
var _user = DATA._user;
|
||||
var email = auth.verifySSA(_user);
|
||||
if (!email) {
|
||||
res.json(403, {error: 'bad_user'});
|
||||
return done();
|
||||
}
|
||||
|
||||
// TODO: Check for valid game. (issue #57)
|
||||
var game = DATA.game;
|
||||
if (!game) {
|
||||
|
@ -295,9 +264,7 @@ module.exports = function(server) {
|
|||
}));
|
||||
}
|
||||
|
||||
user.getUserFromEmail(client, email, db.plsNoError(res, done, function(authenticator) {
|
||||
if (!authenticator.permissions ||
|
||||
(!authenticator.permissions.admin && !authenticator.permissions.reviewer)) {
|
||||
if (!user.permissions || (!user.permissions.admin && !user.permissions.reviewer)) {
|
||||
res.json(403, {error: 'bad_permission'});
|
||||
return done();
|
||||
}
|
||||
|
@ -310,5 +277,4 @@ module.exports = function(server) {
|
|||
removeFeatured(client, game, JSON.parse(genres));
|
||||
}));
|
||||
}));
|
||||
}));
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче