Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit f9da51c

Browse files
committed
Merge branch 'dev' of github.com:cloudspokes/tc-api into dev
2 parents e489e3a + ad0256d commit f9da51c

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

actions/srmRoundQuestions.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,21 @@ var DATE_FORMAT = "YYYY-MM-DD HH:mm";
3434
*/
3535
var getRoundQuestionAnswers = function (api, connection, dbConnectionMap, next) {
3636
var helper = api.helper,
37+
caller = connection.caller,
3738
result = [],
3839
questionId = Number(connection.params.questionId);
3940

4041
async.waterfall([
4142
function (cb) {
42-
cb(helper.checkAdmin(connection, 'Authorized information needed.', 'Admin access only.'));
43+
if (!helper.isAdmin(caller) && !caller.isWebArenaSuper) {
44+
if (!helper.isMember(caller)) {
45+
cb(new UnauthorizedError("Authorized information needed."));
46+
} else {
47+
cb(new ForbiddenError("Admin or web Arena super user only."));
48+
}
49+
} else {
50+
cb();
51+
}
4352
}, function (cb) {
4453
cb(helper.checkIdParameter(questionId, "questionId"));
4554
}, function (cb) {

test/test.srmRoundQuestions.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,19 @@ describe('SRM Round Questions APIs', function () {
251251
assertError("/v2/data/srm/rounds/1000000/answers", null, 401, "Authorized information needed.", done);
252252
});
253253

254-
it("Admin access only.", function (done) {
255-
assertError("/v2/data/srm/rounds/1000000/answers", 'user', 403, "Admin access only.", done);
254+
it("Admin or web arena only.", function (done) {
255+
assertError("/v2/data/srm/rounds/1000000/answers", 'user', 403, "Admin or web Arena super user only.", done);
256256
});
257257

258+
// Only admin or web arena super user can get into this step
258259
it("questionId should be number.", function (done) {
259260
assertError("/v2/data/srm/rounds/aaa/answers", 'heffan', 400, "questionId should be number.", done);
260261
});
261262

263+
it("questionId should be number.", function (done) {
264+
assertError("/v2/data/srm/rounds/aaa/answers", 'ksmith', 400, "questionId should be number.", done);
265+
});
266+
262267
it("questionId should be Integer.", function (done) {
263268
assertError("/v2/data/srm/rounds/100000.01/answers", 'heffan', 400, "questionId should be Integer.", done);
264269
});

0 commit comments

Comments
 (0)