- `getUserFromEmail` now returns an error if no user was found, which I believe is the correct behaviour, and added a check in `login.js` to account for this
- `list.js` now fetches the entire game object instead of the public object so it can check the game's `status` property correctly, then maps them to public objects when returning them as a response
This commit is contained in:
Andrew Richardson 2014-02-26 18:50:07 -08:00
Родитель 6c01e454ca
Коммит 4ca3057083
3 изменённых файлов: 7 добавлений и 5 удалений

Просмотреть файл

@ -381,7 +381,7 @@ function getUserFromEmail(client, email, callback) {
if (err && err !== 'no_such_user') {
callback(err);
} else if (!id) {
callback(null, null);
callback('no_such_user');
} else {
getUserFromID(client, id, callback);
}

Просмотреть файл

@ -59,7 +59,7 @@ module.exports = function(server) {
}
var permissions = userData.permissions;
for (var p in Object.keys(permissions)) {
for (var p in permissions) {
// 'status' should only be accessible to reviewers and admins
if (permissions[p] && (p === 'reviewer' || p === 'admin')) {
return fetchGames();
@ -80,7 +80,7 @@ module.exports = function(server) {
// TODO: Filter only 'count' games without having to fetch them all first
// (will be somewhat tricky since we need to ensure order to do pagination
// properly, and we use UUIDs for game keys that have no logical order in the db)
gamelib.getPublicGameObjList(client, null, function(games) {
gamelib.getGameList(client, null, function(games) {
var filteredGames = games;
if (statusFilter) {
// Filter for games matching the provided status
@ -89,7 +89,9 @@ module.exports = function(server) {
});
}
// Pick the first 'count' games
var gamesUpToCount = _.first(filteredGames, count);
var gamesUpToCount = _.first(filteredGames, count).map(function(game) {
return gamelib.publicGameObj(game);
});
res.json(gamesUpToCount);
done();
});

Просмотреть файл

@ -37,7 +37,7 @@ module.exports = function(server) {
var client = db.redis();
var email = body.email;
user.getUserFromEmail(client, email, function(err, resp) {
if (err) {
if (err && err !== 'no_such_user') {
res.json(500, {error: err});
return;
}