From 0ab234a61c41677af5b8a972b230ac75a7e9824a Mon Sep 17 00:00:00 2001 From: Vyacheslav V Sokolov Date: Mon, 19 Jun 2017 21:52:23 +0700 Subject: [PATCH 01/17] Improve challenge visibility control (#501) * IMPROVE CHALLENGE VISIBILITY CONTROL (https://www.topcoder.com/challenge-details/30057891/?type=develop) Verification guide: docs/Verification_Guide-Improve Challenge Visibility Control.doc * Restoring an accidentially modified file * Fixed the case with a challenge that doesn't have eligibility * Shared the eligibility verification with challengeRegistration. The eligibility check routine is now in challengeHelper and can be added anywhere by a couple of simple lines of code. --- actions/challengeRegistration.js | 39 +- actions/challenges.js | 38 +- db_scripts/test_eligibility.delete.sql | 39 ++ db_scripts/test_eligibility.insert.sql | 219 ++++++++++ ...e-Improve Challenge Visibility Control.doc | Bin 0 -> 52736 bytes initializers/challengeHelper.js | 77 +++- initializers/middleware.js | 7 +- initializers/v3client.js | 143 +++++++ package.json | 2 + queries/challenge_registration_validations | 10 - .../get_challenge_accessibility_and_groups | 21 + ...et_challenge_accessibility_and_groups.json | 5 + ...Visibility_Control.postman_collection.json | 386 ++++++++++++++++++ ...isibility_Control.postman_environment.json | 34 ++ test/scripts/mock_v3.js | 73 ++++ 15 files changed, 1037 insertions(+), 56 deletions(-) create mode 100644 db_scripts/test_eligibility.delete.sql create mode 100644 db_scripts/test_eligibility.insert.sql create mode 100644 docs/Verification_Guide-Improve Challenge Visibility Control.doc create mode 100644 initializers/v3client.js create mode 100644 queries/get_challenge_accessibility_and_groups create mode 100644 queries/get_challenge_accessibility_and_groups.json create mode 100644 test/postman/New_Challenge_Visibility_Control.postman_collection.json create mode 100644 test/postman/New_Challenge_Visibility_Control.postman_environment.json create mode 100644 test/scripts/mock_v3.js diff --git a/actions/challengeRegistration.js b/actions/challengeRegistration.js index f50077b66..9424951ef 100644 --- a/actions/challengeRegistration.js +++ b/actions/challengeRegistration.js @@ -3,8 +3,8 @@ * * The APIs to register a challenge (studio category or software category) for the current logged-in user. * - * @version 1.7 - * @author ecnu_haozi, xjtufreeman, bugbuka, flytoj2ee, muzehyun + * @version 1.8 + * @author ecnu_haozi, xjtufreeman, bugbuka, flytoj2ee, muzehyun, GFalcon * * changes in 1.1: * Combine Challenge Registration API(BUGR-11058) @@ -27,6 +27,9 @@ * * changes in 1.7: * Avoid reliability info set if there is none for new user. + * + * changes in 1.8: + * Added the verification of the challenge's eligibility */ "use strict"; @@ -880,19 +883,31 @@ exports.registerChallenge = { } else { api.helper.checkUserActivated(connection.caller.handle, api, connection.dbConnectionMap, function (err, inactive) { var fail = err || inactive; - if (fail) cb(fail); - else api.dataAccess.executeQuery('check_challenge_exists', {challengeId: challengeId}, connection.dbConnectionMap, cb); + if (fail) { + cb(fail); + } else { + api.dataAccess.executeQuery('check_challenge_exists', {challengeId: challengeId}, connection.dbConnectionMap, cb); + } }, "You must activate your account in order to participate. Please check your e-mail in order to complete the activation process, or contact support@topcoder.com if you did not receive an e-mail."); } - }, function (result, cb) { - if (result.length > 0) { - if (result[0].is_studio) { - registerStudioChallengeAction(api, connection, next); - } else { - registerSoftwareChallengeAction(api, connection, next); - } - } else { + }, function(result, cb) { + // If the challenge is not found in the tcs_catalog:project table, + if (result.length === 0) { + // Do nothing, do not register cb(); + return; + } + var isStudio = result[0].isStudio !== 0; + api.challengeHelper.checkUserChallengeEligibility(connection, challengeId, function (err) { + cb(err, isStudio); + }); + }, function (isStudio, cb) { + if (_.isUndefined(isStudio)) { + cb(); + } else if (isStudio) { + registerStudioChallengeAction(api, connection, next); + } else { + registerSoftwareChallengeAction(api, connection, next); } } ], function (err) { diff --git a/actions/challenges.js b/actions/challenges.js index 0c40bbf2b..53266e7a8 100755 --- a/actions/challenges.js +++ b/actions/challenges.js @@ -1,9 +1,9 @@ /* * Copyright (C) 2013 - 2014 TopCoder Inc., All Rights Reserved. * - * @version 1.31 + * @version 1.32 * @author Sky_, mekanizumu, TCSASSEMBLER, freegod, Ghost_141, kurtrips, xjtufreeman, ecnu_haozi, hesibo, LazyChild, - * @author isv, muzehyun, bugbuka + * @author isv, muzehyun, bugbuka, GFalcon * @changes from 1.0 * merged with Member Registration API * changes in 1.1: @@ -79,9 +79,12 @@ * - Update challenge type filter. * Changes in 1.31: * - Remove screeningScorecardId and reviewScorecardId from search challenges api. + * Changes in 1.32: + * - validateChallenge function now checks if an user belongs to a group via + * user_group_xref for old challenges and by calling V3 API for new ones. */ "use strict"; -/*jslint stupid: true, unparam: true, continue: true */ +/*jslint stupid: true, unparam: true, continue: true, nomen: true */ require('datejs'); var fs = require('fs'); @@ -851,7 +854,7 @@ var addFilter = function (sql, filter, isMyChallenges, helper, caller) { * @since 1.10 */ function validateChallenge(api, connection, dbConnectionMap, challengeId, isStudio, callback) { - var error, sqlParams, helper = api.helper; + var error, sqlParams, helper = api.helper, userId = (connection.caller.userId || 0); async.waterfall([ function (cb) { error = helper.checkPositiveInteger(challengeId, 'challengeId') || @@ -862,31 +865,18 @@ function validateChallenge(api, connection, dbConnectionMap, challengeId, isStud } sqlParams = { challengeId: challengeId, - user_id: connection.caller.userId || 0 + user_id: userId }; - async.parallel({ - accessibility: function (cbx) { - api.dataAccess.executeQuery('check_user_challenge_accessibility', sqlParams, dbConnectionMap, cbx); - }, - exists: function (cbx) { - api.dataAccess.executeQuery('check_challenge_exists', sqlParams, dbConnectionMap, cbx); - } - }, cb); + api.dataAccess.executeQuery('check_challenge_exists', sqlParams, dbConnectionMap, cb); }, function (res, cb) { - if (res.exists.length === 0 || Boolean(res.exists[0].is_studio) !== isStudio) { + // If the record with this callengeId doesn't exist in 'project' table + // or there's a studio/software mismatch + if (res.length === 0 || Boolean(res[0].is_studio) !== isStudio) { cb(new NotFoundError("Challenge not found.")); return; } - var access = res.accessibility[0]; - if (access.is_private && !access.has_access && connection.caller.accessLevel !== "admin") { - if (connection.caller.accessLevel === "anon") { - cb(new UnauthorizedError()); - } else { - cb(new ForbiddenError()); - } - return; - } - cb(); + // Check the eligibility + api.challengeHelper.checkUserChallengeEligibility(connection, challengeId, cb); } ], callback); } diff --git a/db_scripts/test_eligibility.delete.sql b/db_scripts/test_eligibility.delete.sql new file mode 100644 index 000000000..5f77f6c44 --- /dev/null +++ b/db_scripts/test_eligibility.delete.sql @@ -0,0 +1,39 @@ +DATABASE common_oltp; + +DELETE FROM user_group_xref WHERE group_id > 3330000 AND group_id < 3330100; +DELETE FROM security_groups WHERE group_id > 3330000 AND group_id < 3330100; +DELETE FROM group_contest_eligibility WHERE contest_eligibility_id > 1110000 AND contest_eligibility_id < 1110100; +DELETE FROM contest_eligibility WHERE contest_eligibility_id > 1110000 AND contest_eligibility_id < 1110100; + +DATABASE informixoltp; + +-- UPDATE coder SET comp_country_code = NULL WHERE user_id = 132458; + +DATABASE tcs_catalog; + +DELETE FROM notification WHERE project_id > 1110000 AND project_id < 1110100; +DELETE FROM project_result WHERE project_id > 1110000 AND project_id < 1110100; +DELETE FROM project_user_audit WHERE project_id > 1110000 AND project_id < 1110100; +DELETE FROM component_inquiry WHERE project_id > 1110000 AND project_id < 1110100; +DELETE FROM resource_info WHERE resource_id IN (SELECT resource_id FROM resource WHERE project_id > 1110000 AND project_id < 1110100); +DELETE FROM resource WHERE project_id > 1110000 AND project_id < 1110100; + +DELETE FROM project_info WHERE project_id > 1110000 AND project_id < 1110100; +DELETE FROM comp_versions WHERE component_id = 3330333; +DELETE FROM comp_catalog WHERE component_id = 3330333; +DELETE FROM project_phase WHERE project_id > 1110000 AND project_id < 1110100; +DELETE FROM project WHERE project_id > 1110000 AND project_id < 1110100; + +DELETE FROM review_item_comment WHERE review_item_comment_id > 7770000 AND review_item_id < 7770100; +DELETE FROM review_item WHERE review_item_id > 5550000 AND review_item_id < 5550100; +DELETE FROM review WHERE review_id > 4440000 AND review_id < 4440100; +DELETE FROM scorecard_question WHERE scorecard_question_id = 3330333; +DELETE FROM scorecard_section WHERE scorecard_section_id = 3330333; +DELETE FROM scorecard_group WHERE scorecard_group_id = 3330333; +DELETE FROM scorecard WHERE scorecard_id = 3330333; +DELETE FROM submission WHERE submission_id > 2220000 AND submission_id < 2220100; +DELETE FROM prize WHERE project_id > 2220000 AND project_id < 2220100; +DELETE FROM upload WHERE project_id > 2220000 AND project_id < 2220100; +DELETE FROM resource WHERE project_id > 2220000 AND project_id < 2220100; +DELETE FROM project_phase WHERE project_id > 2220000 AND project_id < 2220100; +DELETE FROM project WHERE project_id > 2220000 AND project_id < 2220100; diff --git a/db_scripts/test_eligibility.insert.sql b/db_scripts/test_eligibility.insert.sql new file mode 100644 index 000000000..8bb746502 --- /dev/null +++ b/db_scripts/test_eligibility.insert.sql @@ -0,0 +1,219 @@ +DATABASE tcs_catalog; + +INSERT INTO project (project_id, project_status_id, project_category_id, create_user, create_date, modify_user, modify_date) + VALUES (2220001, 1, 14, "132456", CURRENT, "132456", CURRENT); +INSERT INTO project (project_id, project_status_id, project_category_id, create_user, create_date, modify_user, modify_date) + VALUES (2220002, 1, 14, "132456", CURRENT, "132456", CURRENT); +INSERT INTO project (project_id, project_status_id, project_category_id, create_user, create_date, modify_user, modify_date) + VALUES (2220003, 1, 14, "132456", CURRENT, "132456", CURRENT); +INSERT INTO project (project_id, project_status_id, project_category_id, create_user, create_date, modify_user, modify_date) + VALUES (2220004, 1, 14, "132456", CURRENT, "132456", CURRENT); +INSERT INTO project (project_id, project_status_id, project_category_id, create_user, create_date, modify_user, modify_date) + VALUES (2220005, 1, 14, "132456", CURRENT, "132456", CURRENT); + +INSERT INTO project_phase (project_phase_id, project_id, phase_type_id, phase_status_id, scheduled_start_time, scheduled_end_time, duration, create_user, create_date, modify_user, modify_date) + VALUES (7770001, 2220001, 17, 3, CURRENT, CURRENT, 0, "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_phase (project_phase_id, project_id, phase_type_id, phase_status_id, scheduled_start_time, scheduled_end_time, duration, create_user, create_date, modify_user, modify_date) + VALUES (7770002, 2220002, 17, 3, CURRENT, CURRENT, 0, "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_phase (project_phase_id, project_id, phase_type_id, phase_status_id, scheduled_start_time, scheduled_end_time, duration, create_user, create_date, modify_user, modify_date) + VALUES (7770003, 2220003, 17, 3, CURRENT, CURRENT, 0, "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_phase (project_phase_id, project_id, phase_type_id, phase_status_id, scheduled_start_time, scheduled_end_time, duration, create_user, create_date, modify_user, modify_date) + VALUES (7770004, 2220004, 17, 3, CURRENT, CURRENT, 0, "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_phase (project_phase_id, project_id, phase_type_id, phase_status_id, scheduled_start_time, scheduled_end_time, duration, create_user, create_date, modify_user, modify_date) + VALUES (7770005, 2220005, 17, 3, CURRENT, CURRENT, 0, "132456", CURRENT, "132456", CURRENT); + +INSERT INTO resource (resource_id, resource_role_id, project_id, project_phase_id, user_id, create_user, create_date, modify_user, modify_date) + VALUES (8880001, 20, 2220001, 7770001, 132456, "132456", CURRENT, "132456", CURRENT); +INSERT INTO resource (resource_id, resource_role_id, project_id, project_phase_id, user_id, create_user, create_date, modify_user, modify_date) + VALUES (8880002, 20, 2220002, 7770002, 132456, "132456", CURRENT, "132456", CURRENT); +INSERT INTO resource (resource_id, resource_role_id, project_id, project_phase_id, user_id, create_user, create_date, modify_user, modify_date) + VALUES (8880003, 20, 2220003, 7770003, 132456, "132456", CURRENT, "132456", CURRENT); +INSERT INTO resource (resource_id, resource_role_id, project_id, project_phase_id, user_id, create_user, create_date, modify_user, modify_date) + VALUES (8880004, 20, 2220004, 7770004, 132456, "132456", CURRENT, "132456", CURRENT); +INSERT INTO resource (resource_id, resource_role_id, project_id, project_phase_id, user_id, create_user, create_date, modify_user, modify_date) + VALUES (8880005, 20, 2220005, 7770005, 132456, "132456", CURRENT, "132456", CURRENT); + +INSERT INTO upload (upload_id, project_id, resource_id, upload_type_id, upload_status_id, parameter, create_user, create_date, modify_user, modify_date) + VALUES (9990001, 2220001, 8880001, 1, 1, "---", "132456", CURRENT, "132456", CURRENT); +INSERT INTO upload (upload_id, project_id, resource_id, upload_type_id, upload_status_id, parameter, create_user, create_date, modify_user, modify_date) + VALUES (9990002, 2220002, 8880002, 1, 1, "---", "132456", CURRENT, "132456", CURRENT); +INSERT INTO upload (upload_id, project_id, resource_id, upload_type_id, upload_status_id, parameter, create_user, create_date, modify_user, modify_date) + VALUES (9990003, 2220003, 8880003, 1, 1, "---", "132456", CURRENT, "132456", CURRENT); +INSERT INTO upload (upload_id, project_id, resource_id, upload_type_id, upload_status_id, parameter, create_user, create_date, modify_user, modify_date) + VALUES (9990004, 2220004, 8880004, 1, 1, "---", "132456", CURRENT, "132456", CURRENT); +INSERT INTO upload (upload_id, project_id, resource_id, upload_type_id, upload_status_id, parameter, create_user, create_date, modify_user, modify_date) + VALUES (9990005, 2220005, 8880005, 1, 1, "---", "132456", CURRENT, "132456", CURRENT); + +INSERT INTO prize (prize_id, project_id, place, prize_amount, prize_type_id, number_of_submissions, create_user, create_date, modify_user, modify_date) + VALUES (1110001, 2220001, 1, 1000, 14, 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO prize (prize_id, project_id, place, prize_amount, prize_type_id, number_of_submissions, create_user, create_date, modify_user, modify_date) + VALUES (1110002, 2220002, 1, 1000, 14, 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO prize (prize_id, project_id, place, prize_amount, prize_type_id, number_of_submissions, create_user, create_date, modify_user, modify_date) + VALUES (1110003, 2220003, 1, 1000, 14, 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO prize (prize_id, project_id, place, prize_amount, prize_type_id, number_of_submissions, create_user, create_date, modify_user, modify_date) + VALUES (1110004, 2220004, 1, 1000, 14, 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO prize (prize_id, project_id, place, prize_amount, prize_type_id, number_of_submissions, create_user, create_date, modify_user, modify_date) + VALUES (1110005, 2220005, 1, 1000, 14, 1, "132456", CURRENT, "132456", CURRENT); + +INSERT INTO submission (submission_id, upload_id, submission_status_id, submission_type_id, create_user, create_date, modify_user, modify_date, prize_id) + VALUES (2220001, 9990001, 1, 3, "132456", CURRENT, "132456", CURRENT, 1110001); +INSERT INTO submission (submission_id, upload_id, submission_status_id, submission_type_id, create_user, create_date, modify_user, modify_date, prize_id) + VALUES (2220002, 9990002, 1, 3, "132456", CURRENT, "132456", CURRENT, 1110002); +INSERT INTO submission (submission_id, upload_id, submission_status_id, submission_type_id, create_user, create_date, modify_user, modify_date, prize_id) + VALUES (2220003, 9990003, 1, 3, "132456", CURRENT, "132456", CURRENT, 1110003); +INSERT INTO submission (submission_id, upload_id, submission_status_id, submission_type_id, create_user, create_date, modify_user, modify_date, prize_id) + VALUES (2220004, 9990004, 1, 3, "132456", CURRENT, "132456", CURRENT, 1110004); +INSERT INTO submission (submission_id, upload_id, submission_status_id, submission_type_id, create_user, create_date, modify_user, modify_date, prize_id) + VALUES (2220005, 9990005, 1, 3, "132456", CURRENT, "132456", CURRENT, 1110005); + +INSERT INTO scorecard (scorecard_id, scorecard_status_id, scorecard_type_id, project_category_id, name, version, min_score, max_score, create_user, create_date, modify_user, modify_date, version_number) + VALUES (3330333, 1, 7, 14, "---", "---", 0, 100, "132456", CURRENT, "132456", CURRENT, 1); + +INSERT INTO scorecard_group (scorecard_group_id, scorecard_id, name, weight, sort, create_user, create_date, modify_user, modify_date, version) + VALUES (3330333, 3330333, "---", 100, 1, "132456", CURRENT, "132456", CURRENT, 1); + +INSERT INTO scorecard_section (scorecard_section_id, scorecard_group_id, name, weight, sort, create_user, create_date, modify_user, modify_date, version) + VALUES (3330333, 3330333, "---", 100, 1, "132456", CURRENT, "132456", CURRENT, 1); + +INSERT INTO scorecard_question (scorecard_question_id, scorecard_question_type_id, scorecard_section_id, description, weight, sort, upload_document, upload_document_required, create_user, create_date, modify_user, modify_date, version) + VALUES (3330333, 1, 3330333, '---', 100, 1, 0, 0, "132456", CURRENT, "132456", CURRENT, 1); + +INSERT INTO review (review_id, resource_id, submission_id, project_phase_id, scorecard_id, committed, create_user, create_date, modify_user, modify_date) + VALUES (4440001, 8880001, 2220001, 7770001, 3330333, 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO review (review_id, resource_id, submission_id, project_phase_id, scorecard_id, committed, create_user, create_date, modify_user, modify_date) + VALUES (4440002, 8880002, 2220002, 7770002, 3330333, 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO review (review_id, resource_id, submission_id, project_phase_id, scorecard_id, committed, create_user, create_date, modify_user, modify_date) + VALUES (4440003, 8880003, 2220003, 7770003, 3330333, 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO review (review_id, resource_id, submission_id, project_phase_id, scorecard_id, committed, create_user, create_date, modify_user, modify_date) + VALUES (4440004, 8880004, 2220004, 7770004, 3330333, 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO review (review_id, resource_id, submission_id, project_phase_id, scorecard_id, committed, create_user, create_date, modify_user, modify_date) + VALUES (4440005, 8880005, 2220005, 7770005, 3330333, 1, "132456", CURRENT, "132456", CURRENT); + +INSERT INTO review_item (review_item_id, review_id, scorecard_question_id, upload_id, answer, sort, create_user, create_date, modify_user, modify_date) + VALUES (5550001, 4440001, 3330333, 9990001, "---", 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO review_item (review_item_id, review_id, scorecard_question_id, upload_id, answer, sort, create_user, create_date, modify_user, modify_date) + VALUES (5550002, 4440002, 3330333, 9990002, "---", 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO review_item (review_item_id, review_id, scorecard_question_id, upload_id, answer, sort, create_user, create_date, modify_user, modify_date) + VALUES (5550003, 4440003, 3330333, 9990003, "---", 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO review_item (review_item_id, review_id, scorecard_question_id, upload_id, answer, sort, create_user, create_date, modify_user, modify_date) + VALUES (5550004, 4440004, 3330333, 9990004, "---", 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO review_item (review_item_id, review_id, scorecard_question_id, upload_id, answer, sort, create_user, create_date, modify_user, modify_date) + VALUES (5550005, 4440005, 3330333, 9990005, "---", 1, "132456", CURRENT, "132456", CURRENT); + +INSERT INTO review_item_comment (review_item_comment_id, resource_id, review_item_id, comment_type_id, content, sort, create_user, create_date, modify_user, modify_date) + VALUES (7770001, 8880001, 5550001, 1, "The current user has the right to view this challenge", 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO review_item_comment (review_item_comment_id, resource_id, review_item_id, comment_type_id, content, sort, create_user, create_date, modify_user, modify_date) + VALUES (7770002, 8880002, 5550002, 1, "The current user has the right to view this challenge", 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO review_item_comment (review_item_comment_id, resource_id, review_item_id, comment_type_id, content, sort, create_user, create_date, modify_user, modify_date) + VALUES (7770003, 8880003, 5550003, 1, "The current user has the right to view this challenge", 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO review_item_comment (review_item_comment_id, resource_id, review_item_id, comment_type_id, content, sort, create_user, create_date, modify_user, modify_date) + VALUES (7770004, 8880004, 5550004, 1, "The current user has the right to view this challenge", 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO review_item_comment (review_item_comment_id, resource_id, review_item_id, comment_type_id, content, sort, create_user, create_date, modify_user, modify_date) + VALUES (7770005, 8880005, 5550005, 1, "The current user has the right to view this challenge", 1, "132456", CURRENT, "132456", CURRENT); + +INSERT INTO project (project_id, project_status_id, project_category_id, create_user, create_date, modify_user, modify_date) + VALUES (1110001, 1, 14, "132456", CURRENT, "132456", CURRENT); +INSERT INTO project (project_id, project_status_id, project_category_id, create_user, create_date, modify_user, modify_date) + VALUES (1110002, 1, 14, "132456", CURRENT, "132456", CURRENT); +INSERT INTO project (project_id, project_status_id, project_category_id, create_user, create_date, modify_user, modify_date) + VALUES (1110003, 1, 14, "132456", CURRENT, "132456", CURRENT); +INSERT INTO project (project_id, project_status_id, project_category_id, create_user, create_date, modify_user, modify_date) + VALUES (1110004, 1, 14, "132456", CURRENT, "132456", CURRENT); +INSERT INTO project (project_id, project_status_id, project_category_id, create_user, create_date, modify_user, modify_date) + VALUES (1110005, 1, 14, "132456", CURRENT, "132456", CURRENT); + +INSERT INTO project_phase (project_phase_id, project_id, phase_type_id, phase_status_id, scheduled_start_time, scheduled_end_time, duration, create_user, create_date, modify_user, modify_date) + VALUES (2220001, 1110001, 1, 2, CURRENT, CURRENT, 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_phase (project_phase_id, project_id, phase_type_id, phase_status_id, scheduled_start_time, scheduled_end_time, duration, create_user, create_date, modify_user, modify_date) + VALUES (2220002, 1110002, 1, 2, CURRENT, CURRENT, 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_phase (project_phase_id, project_id, phase_type_id, phase_status_id, scheduled_start_time, scheduled_end_time, duration, create_user, create_date, modify_user, modify_date) + VALUES (2220003, 1110003, 1, 2, CURRENT, CURRENT, 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_phase (project_phase_id, project_id, phase_type_id, phase_status_id, scheduled_start_time, scheduled_end_time, duration, create_user, create_date, modify_user, modify_date) + VALUES (2220004, 1110004, 1, 2, CURRENT, CURRENT, 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_phase (project_phase_id, project_id, phase_type_id, phase_status_id, scheduled_start_time, scheduled_end_time, duration, create_user, create_date, modify_user, modify_date) + VALUES (2220005, 1110005, 1, 2, CURRENT, CURRENT, 1, "132456", CURRENT, "132456", CURRENT); + +INSERT INTO comp_catalog (component_id, current_version, component_name, status_id, modify_date, public_ind) + VALUES (3330333, 1, "---", 1, CURRENT, 0); + +INSERT INTO comp_versions (comp_vers_id, component_id, version, version_text, phase_id, phase_time, price, modify_date) + VALUES (4440444, 3330333, 1, "1", 113, CURRENT, 1000, CURRENT); + +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110001, 2, "3330333", "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110002, 2, "3330333", "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110003, 2, "3330333", "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110004, 2, "3330333", "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110005, 2, "3330333", "132456", CURRENT, "132456", CURRENT); + +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110001, 6, 3330333, "Not private", CURRENT, "132456", CURRENT); +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110002, 6, 3330333, "Old logic - access allowed", CURRENT, "132456", CURRENT); +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110003, 6, 3330333, "Old logic - access denied", CURRENT, "132456", CURRENT); +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110004, 6, 3330333, "New logic - access allowed", CURRENT, "132456", CURRENT); +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110005, 6, 3330333, "New logic - access denied", CURRENT, "132456", CURRENT); + +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110001, 79, "---", "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110002, 79, "---", "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110003, 79, "---", "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110004, 79, "---", "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110005, 79, "---", "132456", CURRENT, "132456", CURRENT); + +INSERT INTO project_phase (project_phase_id, project_id, phase_type_id, phase_status_id, scheduled_start_time, scheduled_end_time, duration, create_user, create_date, modify_user, modify_date) + VALUES (3330001, 1110001, 2, 2, CURRENT, CURRENT, 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_phase (project_phase_id, project_id, phase_type_id, phase_status_id, scheduled_start_time, scheduled_end_time, duration, create_user, create_date, modify_user, modify_date) + VALUES (3330002, 1110002, 2, 2, CURRENT, CURRENT, 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_phase (project_phase_id, project_id, phase_type_id, phase_status_id, scheduled_start_time, scheduled_end_time, duration, create_user, create_date, modify_user, modify_date) + VALUES (3330003, 1110003, 2, 2, CURRENT, CURRENT, 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_phase (project_phase_id, project_id, phase_type_id, phase_status_id, scheduled_start_time, scheduled_end_time, duration, create_user, create_date, modify_user, modify_date) + VALUES (3330004, 1110004, 2, 2, CURRENT, CURRENT, 1, "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_phase (project_phase_id, project_id, phase_type_id, phase_status_id, scheduled_start_time, scheduled_end_time, duration, create_user, create_date, modify_user, modify_date) + VALUES (3330005, 1110005, 2, 2, CURRENT, CURRENT, 1, "132456", CURRENT, "132456", CURRENT); + +DATABASE informixoltp; + +UPDATE coder SET comp_country_code = ( + SELECT MIN(country_code) FROM country WHERE country_name = "United States" +) WHERE coder_id = 132458; + +DATABASE common_oltp; + +INSERT INTO contest_eligibility (contest_eligibility_id, contest_id, is_studio) VALUES (1110002, 2220002, 0); +INSERT INTO contest_eligibility (contest_eligibility_id, contest_id, is_studio) VALUES (1110003, 2220003, 0); +INSERT INTO contest_eligibility (contest_eligibility_id, contest_id, is_studio) VALUES (1110004, 2220004, 0); +INSERT INTO contest_eligibility (contest_eligibility_id, contest_id, is_studio) VALUES (1110005, 2220005, 0); + +INSERT INTO security_groups (group_id, description, challenge_group_ind) VALUES (3330001, "Eligibility - Old logic - with user", 0); +INSERT INTO security_groups (group_id, description, challenge_group_ind) VALUES (3330002, "Eligibility - Old logic - no users", 0); +INSERT INTO security_groups (group_id, description, challenge_group_ind) VALUES (3330003, "Eligibility - New logic - with user", 1); +INSERT INTO security_groups (group_id, description, challenge_group_ind) VALUES (3330004, "Eligibility - New logic - no users", 1); + +INSERT INTO user_group_xref (user_group_id, login_id, group_id) VALUES (5550001, 132458, 3330001); + +INSERT INTO group_contest_eligibility (contest_eligibility_id, group_id) VALUES (1110002, 3330001); +INSERT INTO group_contest_eligibility (contest_eligibility_id, group_id) VALUES (1110003, 3330002); +INSERT INTO group_contest_eligibility (contest_eligibility_id, group_id) VALUES (1110004, 3330003); +INSERT INTO group_contest_eligibility (contest_eligibility_id, group_id) VALUES (1110005, 3330004); + +INSERT INTO contest_eligibility (contest_eligibility_id, contest_id, is_studio) VALUES (1110012, 1110002, 0); +INSERT INTO contest_eligibility (contest_eligibility_id, contest_id, is_studio) VALUES (1110013, 1110003, 0); +INSERT INTO contest_eligibility (contest_eligibility_id, contest_id, is_studio) VALUES (1110014, 1110004, 0); +INSERT INTO contest_eligibility (contest_eligibility_id, contest_id, is_studio) VALUES (1110015, 1110005, 0); + +INSERT INTO group_contest_eligibility (contest_eligibility_id, group_id) VALUES (1110012, 3330001); +INSERT INTO group_contest_eligibility (contest_eligibility_id, group_id) VALUES (1110013, 3330002); +INSERT INTO group_contest_eligibility (contest_eligibility_id, group_id) VALUES (1110014, 3330003); +INSERT INTO group_contest_eligibility (contest_eligibility_id, group_id) VALUES (1110015, 3330004); diff --git a/docs/Verification_Guide-Improve Challenge Visibility Control.doc b/docs/Verification_Guide-Improve Challenge Visibility Control.doc new file mode 100644 index 0000000000000000000000000000000000000000..1c2913aaec56e9f7acc508b92ae08a944ff0a3e0 GIT binary patch literal 52736 zcmeHw2|!iF_y0V2z+)8<5e@Z$gh(!+xF-SbxZ#4Dnu>sm3%KA~DH>UtnVNgK=2B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)8CY{uO-YAz`R1U<-Q18m(`9jr zn?CdFXG$;USP%lzJQ zdH3PJWs$xMf+>YBX8AGHF8FSilzKinovFOBicf+)%I1$2q^4cm^5<#t=~SrXk5(Ub iP4chip*VSWL!iv!1T1D4HSNbKe=(CNGT8s+^#32o*MqkJ literal 0 HcmV?d00001 diff --git a/initializers/challengeHelper.js b/initializers/challengeHelper.js index d8d94e75c..2460e3f17 100644 --- a/initializers/challengeHelper.js +++ b/initializers/challengeHelper.js @@ -1,8 +1,8 @@ /* * Copyright (C) 2013 - 2014 TopCoder Inc., All Rights Reserved. * - * @version 1.4 - * @author ecnu_haozi, bugbuka, Ghost_141, muzehyun + * @version 1.5 + * @author ecnu_haozi, bugbuka, Ghost_141, muzehyun, GFalcon * Refactor common code out from challenge.js. * * changes in 1.1: @@ -13,6 +13,9 @@ * - Avoid undefined if rows[0].copilot_type is null. * Changes in 1.4: * - Add template id to challenge terms of use. + * Changes in 1.5: + * - Add the checkUserChallengeEligibility function + * - Removee the obsolete eligibility check in getChallengeTerms */ "use strict"; @@ -135,11 +138,6 @@ exports.challengeHelper = function (api, next) { return; } - if (!rows[0].no_elgibility_req && !rows[0].user_in_eligible_group) { - cb(new ForbiddenError('You are not part of the groups eligible for this challenge.')); - return; - } - // Update check to use flag. if (requireRegOpen && !rows[0].reg_open) { cb(new ForbiddenError('Registration Phase of this challenge is not open.')); @@ -316,8 +314,71 @@ exports.challengeHelper = function (api, next) { } next(null, result.terms); }); + }, + /** + * Check if the user currently logged in has the right to access the specified challenge + * + * @param {Object} connection The connection object for the current request + * @param {Number} challengeId The challenge id. + * @param {Function} next The callback that will receive an error + * if the user is not eligible + * + * @since 1.5 + */ + checkUserChallengeEligibility: function (connection, challengeId, next) { + // Admins can access any challenge + if (connection.caller.accessLevel === 'admin') { + next(); + return; + } + // Query the accessibility information + var userId = (connection.caller.userId || 0); + api.dataAccess.executeQuery('get_challenge_accessibility_and_groups', { + challengeId: challengeId, + user_id: userId + }, connection.dbConnectionMap, function (err, res) { + if (err) { + next(err); + return; + } + // If there's no corresponding record in group_contest_eligibility + // then the challenge is available to all users + if (res.length === 0 + || _.isNull(res[0].challenge_group_ind) + || _.isUndefined(res[0].challenge_group_ind)) { + next(); + return; + } + var error = false; + // Look at the groups + async.some(res, function (record, cbx) { + // Old challenges: check by looking up in common_oltp:user_group_xref + if (record.challenge_group_ind === 0) { + cbx(!(_.isNull(record.user_group_xref_found) || _.isUndefined(record.user_group_xref_found))); + } else { + // New challenges: query the V3 API + api.v3client.isUserInGroup(connection, userId, record.group_id, function (err, result) { + if (err) { + error = err; + cbx(true); + } else { + cbx(result); + } + }); + } + }, function (eligible) { + if (error) { + next(error); + } else if (eligible) { + next(); + } else if (connection.caller.accessLevel === "anon") { + next(new UnauthorizedError()); + } else { + next(new ForbiddenError()); + } + }); + }); } - }; next(); diff --git a/initializers/middleware.js b/initializers/middleware.js index cf370e589..98fb669ce 100644 --- a/initializers/middleware.js +++ b/initializers/middleware.js @@ -2,8 +2,8 @@ /* * Copyright (C) 2013 - 2014 TopCoder Inc., All Rights Reserved. * - * @version 1.3 - * @author vangavroche, TCSASSEMBLER + * @version 1.4 + * @author vangavroche, TCSASSEMBLER, GFalcon * changes in 1.1: * - add cache support (add preCacheProcessor and postCacheProcessor) * changes in 1.2: @@ -12,6 +12,8 @@ * - add authorizationPreProcessor * changes in 1.3: * - add force refresh check for preCacheProcessor + * changes in 1.4: + * - store the authorization token in connection.authToken */ "use strict"; @@ -105,6 +107,7 @@ exports.middleware = function (api, next) { cb(null, reg.exec(authHeader)[1]); } }, function (token, cb) { + connection.authToken = token; jwt.verify(token, api.config.tcConfig.oauthClientSecret, { audience: api.config.tcConfig.oauthClientId }, diff --git a/initializers/v3client.js b/initializers/v3client.js new file mode 100644 index 000000000..dabb7759d --- /dev/null +++ b/initializers/v3client.js @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2017 TopCoder Inc., All Rights Reserved. + * + * V3 API client + * + * @version 1.0 + * @author GFalcon + */ +"use strict"; +/*jslint nomen: true*/ + +var request = require('request'); +var _ = require('underscore'); +var async = require('async'); + +/** + * The URL of the V3 API + */ +var v3url = process.env.TC_API_V3_URL || 'http://localhost:8084/v3/'; + +/** + * Cached V3 API tokens. + * + * This object stores V2 tokens as keys and V3 tokens as values + */ +var tokens = {}; + +/** + * Call the service. It handles both errors and bad response status codes. + * + * @param {Object} params - parameters for a request + * @param {Function} callback - the callback function. + * It will get either an Error object or a response body. + */ +function callService(params, callback) { + params.json = true; + request(params, function (err, response, body) { + if (err) { + callback(err); + return; + } + /*jslint eqeq: true*/ + if (response.statusCode != 200) { + /*jslint eqeq: false*/ + callback(new Error('API V3 returned ' + response.statusCode + ' ' + (response.statusMessage || ''))); + return; + } + callback(null, body); + }); +} + +/** + * Get the V3 API authorization token to use in subsequent calls + * + * @param {Object} connection - the connection object provided by ActionHero + * @param {Function} callback - this function receives either an error, + * a V3 token or nothing at all (if the current connection's user is anonymous) + */ +function getToken(connection, callback) { + // Anonymous + if (_.isUndefined(connection.authToken)) { + callback(); + return; + } + // Cached token + if (!_.isUndefined(tokens[connection.authToken])) { + callback(null, tokens[connection.authToken]); + return; + } + // Get the token by calling the API + callService({ + url: v3url + 'authorizations', + method: 'POST', + body: { + param: { + token: connection.authToken + } + } + }, function (err, body) { + if (err) { + callback(err); + } else { + tokens[connection.authToken] = body.result.content.token; + callback(null, body.result.content.token); + } + }); +} + +/** + * Get IDs of users in the specified group + * + * @param {Object} connection - the connection object provided by ActionHero + * @param {Number} groupId - the group ID + * @param {Function} callback - the callback. Receives either an error + * or the list of group's users an array of numeric IDs + */ +function getGroupMembers(connection, groupId, callback) { + getToken(connection, function (err, token) { + if (err) { + callback(err); + return; + } + callService({ + url: v3url + 'groups/' + groupId + '/members', + method: 'GET', + headers: { + 'Authorization': 'Bearer ' + token + } + }, function (err, body) { + if (err) { + callback(err); + } else { + callback(null, body.result.content.map(function (item) { + return item.memberId; + })); + } + }); + }); +} + +exports.v3client = function (api, next) { + api.v3client = { + /** + * Check if the user belongs to the group + * + * @param {Object} connection - the connection object provided by ActionHero + * @param {Number} userId - the user ID + * @param {Number} groupId - the group ID + * @param {Function} callback - the callback. The second parameter + * is boolean vwhich is true if the user is found in the group. + */ + isUserInGroup: function (connection, userId, groupId, callback) { + getGroupMembers(connection, groupId, function (err, members) { + if (err) { + callback(err); + } else { + callback(null, members.indexOf(userId) >= 0); + } + }); + } + }; + next(); +}; diff --git a/package.json b/package.json index b9daa5614..c3e6dfc2a 100644 --- a/package.json +++ b/package.json @@ -21,9 +21,11 @@ "bcrypt": "0.7.x", "bigdecimal": "0.6.x", "bignum": "0.6.x", + "body-parser": "^1.17.2", "crypto": "0.0.x", "datejs": "0.0.x", "email-templates": "0.1.x", + "express": "^4.15.3", "forums-wrapper": "git://github.com/cloudspokes/forums-wrapper.git#12b57be495c2e10431173522bc9eff60e0575959", "heapdump": "^0.3.6", "highlight.js": ">= 8.3.0", diff --git a/queries/challenge_registration_validations b/queries/challenge_registration_validations index 1b20283f4..4bd4a63de 100644 --- a/queries/challenge_registration_validations +++ b/queries/challenge_registration_validations @@ -4,8 +4,6 @@ select (pp_reg_open.project_id IS NOT NULL) as reg_open, (r.project_id IS NOT NULL) as user_registered, (us.user_id IS NOT NULL) as user_suspended, - (ce.contest_eligibility_id IS NULL) as no_elgibility_req, - (ugx.login_id IS NOT NULL) as user_in_eligible_group, (uax.user_id IS NOT NULL OR coder.coder_id IS NOT NULL) as user_country_banned, (coder2.comp_country_code IS NULL OR coder2.comp_country_code = '') as comp_country_is_null, (cop.copilot_profile_id IS NOT NULL) as user_is_copilot, @@ -28,14 +26,6 @@ left join on us.user_id = @userId@ and us.user_status_type_id = 1 and us.user_status_id = 3 --- Check if user meets eligibility requirements -left outer join ( - contest_eligibility ce join ( - group_contest_eligibility gce left outer join user_group_xref ugx - on ugx.group_id = gce.group_id and ugx.login_id = @userId@ - ) - on ce.contest_eligibility_id = gce.contest_eligibility_id -) on p.project_id = ce.contest_id -- Check user's country left outer join ( informixoltp:user_address_xref uax join ( diff --git a/queries/get_challenge_accessibility_and_groups b/queries/get_challenge_accessibility_and_groups new file mode 100644 index 000000000..6ca557db3 --- /dev/null +++ b/queries/get_challenge_accessibility_and_groups @@ -0,0 +1,21 @@ +SELECT + ce.is_studio, + sg.challenge_group_ind, + ugx.group_id AS user_group_xref_found, + sg.group_id AS group_id +FROM + ( + ( + contest_eligibility ce + LEFT JOIN group_contest_eligibility gce + ON ce.contest_eligibility_id = gce.contest_eligibility_id + ) + LEFT JOIN security_groups sg + ON gce.group_id = sg.group_id + ) + LEFT JOIN ( + SELECT group_id FROM user_group_xref WHERE login_id=@user_id@ + ) ugx + ON ugx.group_id = gce.group_id +WHERE ce.contest_id = @challengeId@ + diff --git a/queries/get_challenge_accessibility_and_groups.json b/queries/get_challenge_accessibility_and_groups.json new file mode 100644 index 000000000..218f37428 --- /dev/null +++ b/queries/get_challenge_accessibility_and_groups.json @@ -0,0 +1,5 @@ +{ + "name" : "get_challenge_accessibility_and_groups", + "db" : "tcs_catalog", + "sqlfile" : "get_challenge_accessibility_and_groups" +} \ No newline at end of file diff --git a/test/postman/New_Challenge_Visibility_Control.postman_collection.json b/test/postman/New_Challenge_Visibility_Control.postman_collection.json new file mode 100644 index 000000000..7dadfd3d1 --- /dev/null +++ b/test/postman/New_Challenge_Visibility_Control.postman_collection.json @@ -0,0 +1,386 @@ +{ + "id": "ba962be9-0d58-f187-8809-008a39bc2240", + "name": "New Challenge Visibility Control", + "description": "", + "order": [], + "folders": [ + { + "id": "712ffa63-a959-e4a3-6af9-84d4f236b2f3", + "name": "Get checkpoints", + "description": "", + "order": [ + "7c7643c6-89ab-641e-b67a-32b3ac91e09e", + "d830ec36-eb8e-9586-c546-14af77cec152", + "2af8f0d9-f3e8-c58a-ca3d-1130e4b07371", + "f545bbfc-36d7-6567-25a8-b4d6634575e7", + "a3ae5124-2077-4ff2-4e02-afae7670bbe5" + ], + "owner": "316251" + }, + { + "id": "cfbf928f-56b8-9813-f8f3-4ac4e342d965", + "name": "Register for challenges", + "description": "", + "order": [ + "4b64d85a-4c08-8ec2-9c3f-50605bd2e09e", + "5224f722-9f4f-07bb-58e7-351512cc66ea", + "60ae89de-4eb1-c0aa-b866-b28b52436e89", + "843d6759-0cc0-a0c6-9fde-60f893f56eac", + "46cf305a-8251-66aa-391c-46def82773a1" + ], + "owner": "316251" + }, + { + "id": "0eeb693c-c6b6-e23b-156d-cff5f21dbb27", + "name": "login", + "description": "", + "order": [ + "6bed8920-6800-0ae0-e63d-b39b05c7f50c", + "fd4cd936-2d4d-a272-f402-d0f7b6cab82f" + ], + "owner": "316251", + "collectionId": "6369974d-65cc-d819-459b-0026549ddb47" + } + ], + "timestamp": 1474156790593, + "owner": "316251", + "public": false, + "requests": [ + { + "id": "2af8f0d9-f3e8-c58a-ca3d-1130e4b07371", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/develop/challenges/checkpoint/2220003", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497550652259, + "name": "Old logic, access denied", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [], + "folder": "712ffa63-a959-e4a3-6af9-84d4f236b2f3" + }, + { + "id": "46cf305a-8251-66aa-391c-46def82773a1", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/1110005/register", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "POST", + "data": null, + "dataMode": "params", + "version": 2, + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497813578982, + "name": "New logic, access denied", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] + }, + { + "id": "4b64d85a-4c08-8ec2-9c3f-50605bd2e09e", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/1110001/register", + "queryParams": [], + "pathVariables": {}, + "pathVariableData": [], + "preRequestScript": null, + "method": "POST", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "data": null, + "dataMode": "params", + "name": "No groups (challenge is not private)", + "description": "", + "descriptionFormat": "html", + "time": 1497813014785, + "version": 2, + "responses": [], + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "folder": "cfbf928f-56b8-9813-f8f3-4ac4e342d965" + }, + { + "id": "5224f722-9f4f-07bb-58e7-351512cc66ea", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/1110002/register", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "POST", + "data": null, + "dataMode": "params", + "version": 2, + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497813399305, + "name": "Old logic, access allowed", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] + }, + { + "id": "60ae89de-4eb1-c0aa-b866-b28b52436e89", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/1110003/register", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "POST", + "data": null, + "dataMode": "params", + "version": 2, + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497813480606, + "name": "Old logic, access denied", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] + }, + { + "id": "6bed8920-6800-0ae0-e63d-b39b05c7f50c", + "headers": "Content-Type: application/json\n", + "url": "{{url}}/auth", + "preRequestScript": null, + "pathVariables": {}, + "method": "POST", + "data": [], + "dataMode": "raw", + "version": 2, + "tests": "var authResponse = JSON.parse(responseBody);\npostman.setEnvironmentVariable(\"authToken\", authResponse.token);\ntests[\"Status code is 200\"] = responseCode.code === 200;\nvar jsonData = JSON.parse(responseBody);\ntests[\"A valid token is returned\"] = !!jsonData.token;", + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1474159263289, + "name": "Login as admin user", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [], + "rawModeData": "{\n \"username\": \"heffan\", \n \"password\": \"password\"\n}", + "folder": "0eeb693c-c6b6-e23b-156d-cff5f21dbb27" + }, + { + "id": "7c7643c6-89ab-641e-b67a-32b3ac91e09e", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/develop/challenges/checkpoint/2220001", + "queryParams": [], + "pathVariables": {}, + "pathVariableData": [], + "preRequestScript": null, + "method": "GET", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "data": null, + "dataMode": "params", + "name": "No groups (challenge is not private)", + "description": "", + "descriptionFormat": "html", + "time": 1497550504090, + "version": 2, + "responses": [], + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "folder": "712ffa63-a959-e4a3-6af9-84d4f236b2f3" + }, + { + "id": "843d6759-0cc0-a0c6-9fde-60f893f56eac", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/1110004/register", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "POST", + "data": null, + "dataMode": "params", + "version": 2, + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497813524683, + "name": "New logic, access allowed", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] + }, + { + "id": "a3ae5124-2077-4ff2-4e02-afae7670bbe5", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/develop/challenges/checkpoint/2220005", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497550755372, + "name": "New logic, access denied", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [], + "folder": "712ffa63-a959-e4a3-6af9-84d4f236b2f3" + }, + { + "id": "d830ec36-eb8e-9586-c546-14af77cec152", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/develop/challenges/checkpoint/2220002", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497550612717, + "name": "Old logic, access allowed", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [], + "folder": "712ffa63-a959-e4a3-6af9-84d4f236b2f3" + }, + { + "id": "f545bbfc-36d7-6567-25a8-b4d6634575e7", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/develop/challenges/checkpoint/2220004", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497550705028, + "name": "New logic, access allowed", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [], + "folder": "712ffa63-a959-e4a3-6af9-84d4f236b2f3" + }, + { + "id": "fd4cd936-2d4d-a272-f402-d0f7b6cab82f", + "headers": "Content-Type: application/json\n", + "url": "{{url}}/auth", + "preRequestScript": null, + "pathVariables": {}, + "method": "POST", + "data": [], + "dataMode": "raw", + "version": 2, + "tests": "var authResponse = JSON.parse(responseBody);\npostman.setEnvironmentVariable(\"authToken\", authResponse.token);\ntests[\"Status code is 200\"] = responseCode.code === 200;\nvar jsonData = JSON.parse(responseBody);\ntests[\"A valid token is returned\"] = !!jsonData.token;", + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1474159245944, + "name": "Log in as ordinary user", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [], + "rawModeData": "{\n \"username\": \"user\", \n \"password\": \"password\"\n}", + "folder": "0eeb693c-c6b6-e23b-156d-cff5f21dbb27" + } + ] +} \ No newline at end of file diff --git a/test/postman/New_Challenge_Visibility_Control.postman_environment.json b/test/postman/New_Challenge_Visibility_Control.postman_environment.json new file mode 100644 index 000000000..143271c12 --- /dev/null +++ b/test/postman/New_Challenge_Visibility_Control.postman_environment.json @@ -0,0 +1,34 @@ +{ + "id": "d761e292-418f-09b5-8b27-9d93eae42f1e", + "name": "New Challenge Visibility Control", + "values": [ + { + "enabled": true, + "key": "url", + "value": "http://localhost:8080/api/v2", + "type": "text" + }, + { + "enabled": true, + "key": "adminToken", + "value": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL3NtYS5hdXRoMC5jb20vIiwic3ViIjoiYWR8MTMyNDU2IiwiYXVkIjoiQ01hQnV3U25ZMFZ1NjhQTHJXYXR2dnUzaUlpR1BoN3QiLCJleHAiOjE1MTAxNTkyNjgsImlhdCI6MTQ3NDE1OTI2OH0.KRgW9TxNOEiEu5YdQnXQO1nKFULIuy7JlzDZdq9QFQY", + "type": "text" + }, + { + "enabled": true, + "key": "userToken", + "value": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL3NtYS5hdXRoMC5jb20vIiwic3ViIjoiYWR8MTMyNDU4IiwiYXVkIjoiQ01hQnV3U25ZMFZ1NjhQTHJXYXR2dnUzaUlpR1BoN3QiLCJleHAiOjE1MTAxNzI0MDgsImlhdCI6MTQ3NDE3MjQwOH0.sIG2FoNiCldizzcTMQ9iAFh-PCigNGBAlicxms6uTkk", + "type": "text" + }, + { + "enabled": true, + "key": "authToken", + "value": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL3NtYS5hdXRoMC5jb20vIiwic3ViIjoiYWR8MTMyNDU4IiwiYXVkIjoiQ01hQnV3U25ZMFZ1NjhQTHJXYXR2dnUzaUlpR1BoN3QiLCJleHAiOjE1MTAyODI4MDMsImlhdCI6MTQ3NDI4MjgwM30.s6q_FRFryMslkWCkR0wPSWwTopkZhHH8g9R_4GPf9m4", + "type": "text" + } + ], + "timestamp": 1497565761064, + "_postman_variable_scope": "environment", + "_postman_exported_at": "2017-06-15T22:29:38.942Z", + "_postman_exported_using": "Postman/5.0.1" +} \ No newline at end of file diff --git a/test/scripts/mock_v3.js b/test/scripts/mock_v3.js new file mode 100644 index 000000000..8df5e8c02 --- /dev/null +++ b/test/scripts/mock_v3.js @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2017 TopCoder Inc., All Rights Reserved. + * + * This is the REST server that mocks some services from the V3 API + * + * @author GFalcon + * @version 1.0 + */ +"use strict"; + +var express = require('express'); +var bodyParser = require('body-parser'); + +var app = express(); + +app.use(bodyParser.json()); + +/* + * Log all incoming requests + */ +/*jslint unparam: true*/ +app.use(function (req, res, next) { + console.info('V3 Request: ' + JSON.stringify({ + path: req.path, + method: req.method, + headers: req.headers, + body: req.body + }, null, ' ')); + next(); +}); +/*jslint unparam: false*/ + +/* + * Return a fake 'authorization token' + */ +/*jslint unparam: true*/ +app.post('/v3/authorizations', function (req, res) { + res.json({ + result: { + content: { + token: 'FAKE-TOKEN' + } + } + }); +}); +/*jslint unparam: false*/ + +/* + * Get group members. Makes each group consist of one user + * (the user from the sample database whose handle is 'user') + * except one group (id 3330004) that doesn't have any users at all + */ +app.get('/v3/groups/:groupId/members', function (req, res) { + /*jslint eqeq: true*/ + if (req.params.groupId != 3330004) { + /*jslint eqeq: false*/ + res.json({ + result: { + content: [{ + memberId: 132458 + }] + } + }); + } else { + res.json({ + result: { + content: [] + } + }); + } +}); + +app.listen(8084); From 092c69dc7a1ea669f9a7f864058d3ba32f2367d4 Mon Sep 17 00:00:00 2001 From: Guiqiang Zhang Date: Tue, 20 Jun 2017 08:05:08 +0800 Subject: [PATCH 02/17] improve the query --- queries/check_user_challenge_accessibility | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/queries/check_user_challenge_accessibility b/queries/check_user_challenge_accessibility index 4ab12d78a..e7d7e9b14 100644 --- a/queries/check_user_challenge_accessibility +++ b/queries/check_user_challenge_accessibility @@ -3,9 +3,9 @@ SELECT 1 FROM contest_eligibility ce INNER JOIN group_contest_eligibility gce ON gce.contest_eligibility_id = ce.contest_eligibility_id - INNER JOIN user_group_xref ugx ON ugx.group_id = gce.group_id + LEFT JOIN user_group_xref ugx ON ugx.group_id = gce.group_id WHERE ce.contest_id = @challengeId@ - AND ugx.login_id = @user_id@) AS has_access + AND ((ugx.login_id = @user_id@ AND gce.group_id < 2000000) OR gce.group_id >= 2000000)) AS has_access , (SELECT 1 FROM contest_eligibility ce From a0b6b3b4a81be58a07e93fbeb1e425a0557a5baa Mon Sep 17 00:00:00 2001 From: skyhit Date: Tue, 20 Jun 2017 08:16:46 +0800 Subject: [PATCH 03/17] update query for groups (#502) --- queries/check_is_related_with_challenge | 2 +- queries/get_open_challenges_count | 2 +- queries/get_past_challenges_count | 2 +- queries/search_past_software_studio_challenges | 2 +- queries/search_past_software_studio_challenges_count | 2 +- queries/search_software_studio_challenges | 2 +- queries/search_software_studio_challenges_count | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/queries/check_is_related_with_challenge b/queries/check_is_related_with_challenge index 5c18c5bb6..ab18cd096 100644 --- a/queries/check_is_related_with_challenge +++ b/queries/check_is_related_with_challenge @@ -5,7 +5,7 @@ SELECT INNER JOIN group_contest_eligibility gce ON gce.contest_eligibility_id = ce.contest_eligibility_id INNER JOIN user_group_xref ugx ON ugx.group_id = gce.group_id WHERE ce.contest_id = @challengeId@ - AND ugx.login_id = @user_id@) AS has_access + AND ((ugx.login_id = @user_id@ AND gce.group_id < 2000000) OR gce.group_id >= 2000000)) AS has_access , (SELECT 1 FROM contest_eligibility ce diff --git a/queries/get_open_challenges_count b/queries/get_open_challenges_count index 863788407..0b65313d6 100644 --- a/queries/get_open_challenges_count +++ b/queries/get_open_challenges_count @@ -16,7 +16,7 @@ AND p.project_category_id = pcl.project_category_id -- Filter out the challenge that user is not belong to. AND (not exists (select contest_id from contest_eligibility where contest_id = p.project_id) or exists(select contest_id from contest_eligibility ce, group_contest_eligibility gce, user_group_xref x - where x.login_id = @user_id@ AND x.group_id = gce.group_id AND gce.contest_eligibility_id = ce.contest_eligibility_id + where ((gce.group_id < 2000000 AND x.group_id = gce.group_id AND x.login_id = @user_id@) OR gce.group_id >= 2000000) AND gce.contest_eligibility_id = ce.contest_eligibility_id AND ce.contest_id = p.project_id)) AND pcl.project_category_id NOT IN (27, 37) --exclude when spec review was a 'contest.' Also exclude MM, which is in there as a 'software' contest. -- start of parameters diff --git a/queries/get_past_challenges_count b/queries/get_past_challenges_count index 0adb68d0f..23b07d5eb 100644 --- a/queries/get_past_challenges_count +++ b/queries/get_past_challenges_count @@ -28,6 +28,6 @@ AND p.tc_direct_project_id = DECODE(@project_id@, 0, p.tc_direct_project_id, @pr -- Filter out the challenge that user is not belong to. AND (not exists (select contest_id from contest_eligibility where contest_id = p.project_id) or exists(select contest_id from contest_eligibility ce, group_contest_eligibility gce, user_group_xref x - where x.login_id = @user_id@ AND x.group_id = gce.group_id AND gce.contest_eligibility_id = ce.contest_eligibility_id + where ((gce.group_id < 2000000 AND x.group_id = gce.group_id AND x.login_id = @user_id@) OR gce.group_id >= 2000000) AND gce.contest_eligibility_id = ce.contest_eligibility_id AND ce.contest_id = p.project_id)) AND not exists (select 1 from resource r, project_info pi82 where r.project_id = p.project_id and r.resource_role_id = 1 and p.project_id = pi82.project_id and project_info_type_id = 82 and pi82.value = 1) diff --git a/queries/search_past_software_studio_challenges b/queries/search_past_software_studio_challenges index 660133285..53ba42220 100644 --- a/queries/search_past_software_studio_challenges +++ b/queries/search_past_software_studio_challenges @@ -105,7 +105,7 @@ AND NVL((cmc_task_id.value), '') = DECODE('@cmc@', '', NVL((cmc_task_id.value), -- Filter out the challenge that user is not belong to. AND (not exists (SELECT contest_id FROM contest_eligibility WHERE contest_id = p.project_id) OR exists(SELECT contest_id FROM contest_eligibility ce, group_contest_eligibility gce, user_group_xref x - WHERE x.login_id = @userId@ AND x.group_id = gce.group_id AND gce.contest_eligibility_id = ce.contest_eligibility_id + WHERE ((gce.group_id < 2000000 AND x.group_id = gce.group_id AND x.login_id = @user_id@) OR gce.group_id >= 2000000) AND gce.contest_eligibility_id = ce.contest_eligibility_id AND ce.contest_id = p.project_id)) and pp.actual_end_time > '2012-01-01 00:00:00' diff --git a/queries/search_past_software_studio_challenges_count b/queries/search_past_software_studio_challenges_count index 95151dbe4..81bd29d3b 100644 --- a/queries/search_past_software_studio_challenges_count +++ b/queries/search_past_software_studio_challenges_count @@ -11,7 +11,7 @@ INNER JOIN project_category_lu pcl on pcl.project_category_id = p.project_catego LEFT JOIN project_info pi1 ON pi1.project_id = p.project_id AND pi1.project_info_type_id = 1 WHERE (not exists (SELECT contest_id FROM contest_eligibility WHERE contest_id = p.project_id) OR exists(SELECT contest_id FROM contest_eligibility ce, group_contest_eligibility gce, user_group_xref x - WHERE x.login_id = 22655028 AND x.group_id = gce.group_id AND gce.contest_eligibility_id = ce.contest_eligibility_id + WHERE ((gce.group_id < 2000000 AND x.group_id = gce.group_id AND x.login_id = 22655028) OR gce.group_id >= 2000000) AND gce.contest_eligibility_id = ce.contest_eligibility_id AND ce.contest_id = p.project_id)) AND pcl.project_category_id NOT IN (27, 37) --exclude when spec review was a 'contest.' Also exclude MM, which is in there as a 'software' contest. AND p.project_status_id IN (4, 5, 6, 7, 8, 9, 10, 11) diff --git a/queries/search_software_studio_challenges b/queries/search_software_studio_challenges index 0f148ac57..18c7c1370 100644 --- a/queries/search_software_studio_challenges +++ b/queries/search_software_studio_challenges @@ -104,7 +104,7 @@ FIRST @pageSize@ -- Filter out the challenge that user is not belong to. AND (not exists (select contest_id from contest_eligibility where contest_id = p.project_id) or exists(select contest_id from contest_eligibility ce, group_contest_eligibility gce, user_group_xref x - where x.login_id = @userId@ AND x.group_id = gce.group_id AND gce.contest_eligibility_id = ce.contest_eligibility_id + where ((gce.group_id < 2000000 AND x.group_id = gce.group_id AND x.login_id = 22655028) OR gce.group_id >= 2000000) AND gce.contest_eligibility_id = ce.contest_eligibility_id AND ce.contest_id = p.project_id)) AND pcl.project_category_id NOT IN (27, 37) --exclude when spec review was a 'contest.' Also exclude MM, which is in there as a 'software' contest. -- start of parameters diff --git a/queries/search_software_studio_challenges_count b/queries/search_software_studio_challenges_count index 50a44e649..ca300b02b 100644 --- a/queries/search_software_studio_challenges_count +++ b/queries/search_software_studio_challenges_count @@ -51,7 +51,7 @@ SELECT count(*) AS total -- Filter out the challenge that user is not belong to. AND (not exists (select contest_id from contest_eligibility where contest_id = p.project_id) or exists(select contest_id from contest_eligibility ce, group_contest_eligibility gce, user_group_xref x - where x.login_id = @userId@ AND x.group_id = gce.group_id AND gce.contest_eligibility_id = ce.contest_eligibility_id + where ((gce.group_id < 2000000 AND x.group_id = gce.group_id AND x.login_id = 22655028) OR gce.group_id >= 2000000) AND gce.contest_eligibility_id = ce.contest_eligibility_id AND ce.contest_id = p.project_id)) AND pcl.project_category_id NOT IN (27, 37) --exclude when spec review was a 'contest.' Also exclude MM, which is in there as a 'software' contest. AND pstatus.project_status_id IN (@project_status_id@) From 29cc5e729459cf107766eb9ac0fc1f3428afbe08 Mon Sep 17 00:00:00 2001 From: skyhit Date: Tue, 20 Jun 2017 09:53:16 +0800 Subject: [PATCH 04/17] Update queries (#503) improve logging for v3 api call --- initializers/v3client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/initializers/v3client.js b/initializers/v3client.js index dabb7759d..7b7ac3c33 100644 --- a/initializers/v3client.js +++ b/initializers/v3client.js @@ -42,7 +42,7 @@ function callService(params, callback) { /*jslint eqeq: true*/ if (response.statusCode != 200) { /*jslint eqeq: false*/ - callback(new Error('API V3 returned ' + response.statusCode + ' ' + (response.statusMessage || ''))); + callback(new Error('API ' + params.url + ' returned ' + response.statusCode + ' ' + (response.statusMessage || ''))); return; } callback(null, body); From 591e2d9fe19357976c3307dae7113101efa71a1a Mon Sep 17 00:00:00 2001 From: Guiqiang Zhang Date: Tue, 20 Jun 2017 10:10:32 +0800 Subject: [PATCH 05/17] should use externalToken field name --- initializers/v3client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/initializers/v3client.js b/initializers/v3client.js index 7b7ac3c33..df8312a37 100644 --- a/initializers/v3client.js +++ b/initializers/v3client.js @@ -73,7 +73,7 @@ function getToken(connection, callback) { method: 'POST', body: { param: { - token: connection.authToken + externalToken: connection.authToken } } }, function (err, body) { From f875a0963a20547549fd645af87a904aff6b7bc1 Mon Sep 17 00:00:00 2001 From: Guiqiang Zhang Date: Tue, 20 Jun 2017 22:00:42 +0800 Subject: [PATCH 06/17] update queries for group checking --- queries/check_is_related_with_challenge | 4 ++-- queries/check_user_challenge_accessibility | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/queries/check_is_related_with_challenge b/queries/check_is_related_with_challenge index ab18cd096..36014d75c 100644 --- a/queries/check_is_related_with_challenge +++ b/queries/check_is_related_with_challenge @@ -1,9 +1,9 @@ SELECT (SELECT - 1 + max(1) FROM contest_eligibility ce INNER JOIN group_contest_eligibility gce ON gce.contest_eligibility_id = ce.contest_eligibility_id - INNER JOIN user_group_xref ugx ON ugx.group_id = gce.group_id + LEFT JOIN user_group_xref ugx ON ugx.group_id = gce.group_id WHERE ce.contest_id = @challengeId@ AND ((ugx.login_id = @user_id@ AND gce.group_id < 2000000) OR gce.group_id >= 2000000)) AS has_access , (SELECT diff --git a/queries/check_user_challenge_accessibility b/queries/check_user_challenge_accessibility index e7d7e9b14..309258da0 100644 --- a/queries/check_user_challenge_accessibility +++ b/queries/check_user_challenge_accessibility @@ -1,6 +1,6 @@ SELECT (SELECT - 1 + max(1) FROM contest_eligibility ce INNER JOIN group_contest_eligibility gce ON gce.contest_eligibility_id = ce.contest_eligibility_id LEFT JOIN user_group_xref ugx ON ugx.group_id = gce.group_id From df292bf5881a9bbc59bc688293a0e7f2e8b030ee Mon Sep 17 00:00:00 2001 From: Vyacheslav V Sokolov Date: Tue, 20 Jun 2017 21:09:45 +0700 Subject: [PATCH 07/17] Improve challenge visibility control: getChallenge and getRegistrants (#504) * IMPROVE CHALLENGE VISIBILITY CONTROL (https://www.topcoder.com/challenge-details/30057891/?type=develop) Verification guide: docs/Verification_Guide-Improve Challenge Visibility Control.doc * Restoring an accidentially modified file * Fixed the case with a challenge that doesn't have eligibility * Shared the eligibility verification with challengeRegistration. The eligibility check routine is now in challengeHelper and can be added anywhere by a couple of simple lines of code. * Improve challenge visibility control: getChallenge and getRegistrants --- actions/challenges.js | 95 ++- db_scripts/test_eligibility.insert.sql | 23 + ...e-Improve Challenge Visibility Control.doc | Bin 52736 -> 56832 bytes initializers/challengeHelper.js | 2 +- queries/check_is_related_with_challenge | 26 +- ...Visibility_Control.postman_collection.json | 640 +++++++++++++++++- 6 files changed, 714 insertions(+), 72 deletions(-) diff --git a/actions/challenges.js b/actions/challenges.js index 53266e7a8..bb4d6ceb9 100755 --- a/actions/challenges.js +++ b/actions/challenges.js @@ -80,8 +80,8 @@ * Changes in 1.31: * - Remove screeningScorecardId and reviewScorecardId from search challenges api. * Changes in 1.32: - * - validateChallenge function now checks if an user belongs to a group via - * user_group_xref for old challenges and by calling V3 API for new ones. + * - validateChallenge, getRegistrants, getChallenge, getSubmissions and getPhases functions now check + * if an user belongs to a group via user_group_xref for old challenges and by calling V3 API for new ones. */ "use strict"; /*jslint stupid: true, unparam: true, continue: true, nomen: true */ @@ -1081,19 +1081,20 @@ var getChallenge = function (api, connection, dbConnectionMap, isStudio, next) { }; // Do the private check. + api.challengeHelper.checkUserChallengeEligibility( + connection, + connection.params.challengeId, + cb + ); + }, function (cb) { api.dataAccess.executeQuery('check_is_related_with_challenge', sqlParams, dbConnectionMap, cb); }, function (result, cb) { - if (result[0].is_private && !result[0].has_access) { - cb(new UnauthorizedError('The user is not allowed to visit the challenge.')); - return; - } - if (result[0].is_manager) { isManager = true; } // If the user has the access to the challenge or is a resource for the challenge then he is related with this challenge. - if (result[0].has_access || result[0].is_related || isManager || helper.isAdmin(caller)) { + if (result[0].is_private || result[0].is_related || isManager || helper.isAdmin(caller)) { isRelated = true; } @@ -3342,33 +3343,32 @@ var getRegistrants = function (api, connection, dbConnectionMap, isStudio, next) }; // Do the private check. - api.dataAccess.executeQuery('check_is_related_with_challenge', sqlParams, dbConnectionMap, cb); - }, function (result, cb) { - if (result[0].is_private && !result[0].has_access) { - cb(new UnauthorizedError('The user is not allowed to visit the challenge.')); - return; - } - + api.challengeHelper.checkUserChallengeEligibility( + connection, + connection.params.challengeId, + cb + ); + }, function (cb) { api.dataAccess.executeQuery('challenge_registrants', sqlParams, dbConnectionMap, cb); }, function (results, cb) { var mapRegistrants = function (results) { - if (!_.isDefined(results)) { - return []; + if (!_.isDefined(results)) { + return []; + } + return _.map(results, function (item) { + var registrant = { + handle: item.handle, + reliability: !_.isDefined(item.reliability) ? "n/a" : item.reliability + "%", + registrationDate: formatDate(item.inquiry_date), + submissionDate: formatDate(item.submission_date) + }; + if (!isStudio) { + registrant.rating = item.rating; + registrant.colorStyle = helper.getColorStyle(item.rating); } - return _.map(results, function (item) { - var registrant = { - handle: item.handle, - reliability: !_.isDefined(item.reliability) ? "n/a" : item.reliability + "%", - registrationDate: formatDate(item.inquiry_date), - submissionDate: formatDate(item.submission_date) - }; - if (!isStudio) { - registrant.rating = item.rating; - registrant.colorStyle = helper.getColorStyle(item.rating); - } - return registrant; - }); - }; + return registrant; + }); + }; registrants = mapRegistrants(results); cb(); } @@ -3440,18 +3440,16 @@ var getSubmissions = function (api, connection, dbConnectionMap, isStudio, next) submission_type: [helper.SUBMISSION_TYPE.challenge.id, helper.SUBMISSION_TYPE.checkpoint.id] }; - async.parallel({ - privateCheck: execQuery("check_is_related_with_challenge"), - challengeStatus: execQuery("get_challenge_status") - }, cb); - }, function (result, cb) { - if (result.privateCheck[0].is_private && !result.privateCheck[0].has_access) { - cb(new UnauthorizedError('The user is not allowed to visit the challenge.')); - return; - } - + api.challengeHelper.checkUserChallengeEligibility( + connection, + connection.params.challengeId, + cb + ); + }, + execQuery("get_challenge_status"), + function (result, cb) { // If the caller is not admin and challenge status is still active. - if (!helper.isAdmin(caller) && result.challengeStatus[0].challenge_status_id === 1) { + if (!helper.isAdmin(caller) && result[0].challenge_status_id === 1) { cb(new BadRequestError("The challenge is not finished.")); return; } @@ -3567,13 +3565,12 @@ var getPhases = function (api, connection, dbConnectionMap, isStudio, next) { }; // Do the private check. - api.dataAccess.executeQuery('check_is_related_with_challenge', sqlParams, dbConnectionMap, cb); - }, function (result, cb) { - if (result[0].is_private && !result[0].has_access) { - cb(new UnauthorizedError('The user is not allowed to visit the challenge.')); - return; - } - + api.challengeHelper.checkUserChallengeEligibility( + connection, + connection.params.challengeId, + cb + ); + }, function (cb) { var execQuery = function (name) { return function (cbx) { api.dataAccess.executeQuery(name, sqlParams, dbConnectionMap, cbx); diff --git a/db_scripts/test_eligibility.insert.sql b/db_scripts/test_eligibility.insert.sql index 8bb746502..994746f08 100644 --- a/db_scripts/test_eligibility.insert.sql +++ b/db_scripts/test_eligibility.insert.sql @@ -150,6 +150,28 @@ INSERT INTO project_info (project_id, project_info_type_id, value, create_user, INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) VALUES (1110005, 2, "3330333", "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110001, 6, "Not private", "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110002, 6, "Old logic - access allowed", "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110003, 6, "Old logic - access denied", "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110004, 6, "New logic - access allowed", "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110005, 6, "New logic - access denied", "132456", CURRENT, "132456", CURRENT); + +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110001, 26, "---", "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110002, 26, "---", "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110003, 26, "---", "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110004, 26, "---", "132456", CURRENT, "132456", CURRENT); +INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) + VALUES (1110005, 26, "---", "132456", CURRENT, "132456", CURRENT); + INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) VALUES (1110001, 6, 3330333, "Not private", CURRENT, "132456", CURRENT); INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) @@ -162,6 +184,7 @@ INSERT INTO project_info (project_id, project_info_type_id, value, create_user, VALUES (1110005, 6, 3330333, "New logic - access denied", CURRENT, "132456", CURRENT); INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) +>>>>>>> upstream/dev VALUES (1110001, 79, "---", "132456", CURRENT, "132456", CURRENT); INSERT INTO project_info (project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date) VALUES (1110002, 79, "---", "132456", CURRENT, "132456", CURRENT); diff --git a/docs/Verification_Guide-Improve Challenge Visibility Control.doc b/docs/Verification_Guide-Improve Challenge Visibility Control.doc index 1c2913aaec56e9f7acc508b92ae08a944ff0a3e0..fd53c55cca92514a1e3731a719129a08120a1bcc 100644 GIT binary patch delta 5309 zcmb8z4^UNA9>DS610*u}Bl6^*;PZjzzeo^B5e=2hB_kt8%g|83$dFiI&2@9Z)y!p@ z{Bw|X$gEZi%eGb?^Fl==av7!CbscM3D{9DbwQ+EF#%;(k*zfN>9zJPz+unPhch5cd z-gECg=iKub6V zoE-l~jL5`T5kHZ&Y!G(n^OH2M^wVoi+LULaPR6rif=FAkNa-w*+PNY*nIdswMkU6Y z&M7wgi7_G<#);IhTM)Z7O()H+d)Rd$yDrK!(-Q6Gq>s%kO`Pwir#5eKY)hiQqa(4) z;xjSUygfD6H<0|FCyzGWQ&Y{->AKnMJp1rCk^$)J3zkVNL(Im!4HIY}>8ABIv-G@DI8T{BZl}@7>|#0IjPZ+(>Y5

e*VFW=-`E7lV3Sfr<8BLtiIh*yt~k7$d>l3bHZKPLF!^M=MTguFeH6u*grlG-uuG<7}2_KTcKJ&~=o1-6cmy*vJ%3W2k zk`lC<+!a%CbEUcRwHkj(s+?_4QJuxEdeXC0uvR7|=E=3AhXl%_5@?=$E+)p#ep*`v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``?mGM?>g!TNPDB3>oTZ6J~B zj8=(NiBySFiBO45iAsq``PDh|@!6%{D^f>ekk3&xaPr^<@ZicOcdM+J0 z#+vt|IN?&1a>nrx2159~fgHA6PTcM<4JDT(k0ggAelL+Gh)1GU_^pS6vHztbFelcmH`KzwjsXE>Gzo z1Pow=Fo=LiFoDd{M%UvTTni^%3nyF)^{$1Z{6)WB`6+&rzRCLs^!(Y#_4(xC_-_V} kPgROT6u)P08CQBmQ95rt)G96NfBt4wlv4H8kB?~n4~Qp6qW}N^ diff --git a/initializers/challengeHelper.js b/initializers/challengeHelper.js index 2460e3f17..66edae75f 100644 --- a/initializers/challengeHelper.js +++ b/initializers/challengeHelper.js @@ -374,7 +374,7 @@ exports.challengeHelper = function (api, next) { } else if (connection.caller.accessLevel === "anon") { next(new UnauthorizedError()); } else { - next(new ForbiddenError()); + next(new ForbiddenError('The user is not allowed to visit the challenge.')); } }); }); diff --git a/queries/check_is_related_with_challenge b/queries/check_is_related_with_challenge index 36014d75c..2e7034109 100644 --- a/queries/check_is_related_with_challenge +++ b/queries/check_is_related_with_challenge @@ -2,21 +2,21 @@ SELECT (SELECT max(1) FROM contest_eligibility ce - INNER JOIN group_contest_eligibility gce ON gce.contest_eligibility_id = ce.contest_eligibility_id - LEFT JOIN user_group_xref ugx ON ugx.group_id = gce.group_id WHERE ce.contest_id = @challengeId@ - AND ((ugx.login_id = @user_id@ AND gce.group_id < 2000000) OR gce.group_id >= 2000000)) AS has_access -, (SELECT - 1 - FROM contest_eligibility ce - WHERE ce.contest_id = @challengeId@) AS is_private -, ( - SELECT +) AS is_private +, (SELECT decode(max(ri.value), null, null, 1) FROM resource r - INNER JOIN resource_info ri ON ri.resource_id = r.resource_id AND ri.resource_info_type_id = 1 + INNER JOIN resource_info ri ON ri.resource_id = r.resource_id AND ri.resource_info_type_id = 1 WHERE r.project_id = @challengeId@ - AND ri.value = @user_id@) AS is_related -, (SELECT max(project_metadata_id) FROM direct_project_metadata m, project p - WHERE metadata_value = @user_id@ AND p.tc_direct_project_id = m.tc_direct_project_id and p.project_id = @challengeId@ AND project_metadata_key_id IN (1, 2, 14)) AS is_manager + AND ri.value = @user_id@ +) AS is_related +, (SELECT + max(project_metadata_id) + FROM direct_project_metadata m, project p + WHERE metadata_value = @user_id@ + AND p.tc_direct_project_id = m.tc_direct_project_id + AND p.project_id = @challengeId@ + AND project_metadata_key_id IN (1, 2, 14) +) AS is_manager FROM dual diff --git a/test/postman/New_Challenge_Visibility_Control.postman_collection.json b/test/postman/New_Challenge_Visibility_Control.postman_collection.json index 7dadfd3d1..3c52fb3e4 100644 --- a/test/postman/New_Challenge_Visibility_Control.postman_collection.json +++ b/test/postman/New_Challenge_Visibility_Control.postman_collection.json @@ -4,6 +4,19 @@ "description": "", "order": [], "folders": [ + { + "id": "cada5a0c-766f-dde0-3c9f-d001a67eddd4", + "name": "Get challenge", + "description": "", + "order": [ + "c383cab7-3145-145e-9da9-846001755460", + "42b84596-9d5a-50e7-76be-c1ad23f98468", + "3246a996-e8f9-5e60-79b9-8aeffcd5392f", + "bf83e2d2-549b-361e-f5cf-66a40d816f0c", + "1af5c911-4627-ad92-085c-63e6fc7b6d9e" + ], + "owner": "316251" + }, { "id": "712ffa63-a959-e4a3-6af9-84d4f236b2f3", "name": "Get checkpoints", @@ -17,6 +30,47 @@ ], "owner": "316251" }, + { + "id": "6b9370a1-5974-a6a6-a961-67e73abaa861", + "name": "Get phases", + "description": "", + "order": [ + "c7d11de6-630a-71bd-4095-cd3c8fb8ab77", + "f5da62a7-9231-5f7a-f44a-f2f14c9ae003", + "d7a050dc-6eaa-f62e-24e4-37d111002d4a", + "c305f2ea-dbfd-f95f-c809-583133af5881", + "0461a7de-3ae1-f873-b667-50d04a43b317" + ], + "owner": "316251", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240" + }, + { + "id": "6a038555-23cd-e79f-1d34-0fb860e305a3", + "name": "Get registrants", + "description": "", + "order": [ + "bcc821a7-0e3a-3454-d900-12af0cc94656", + "70b3453b-1d1a-e411-f8e5-527edb0a2530", + "f73f4e00-c286-d440-ce79-89095d7354dd", + "e97dac4e-c786-27b1-5e4b-fff50b6de93a", + "b3cb44e7-3e5f-897e-5d6f-6179afc52653" + ], + "owner": "316251" + }, + { + "id": "2a873809-800c-ee71-51ad-94f10096709b", + "name": "Get submissions", + "description": "", + "order": [ + "f90179ed-98da-be6d-77ae-9e3aa4199b5c", + "f915c206-b3fe-a4be-1094-bc8a448cb467", + "d3e5ca45-334d-fb54-1fd7-46f8e7b82841", + "f8e9d38f-8d8d-6e63-4978-6e3546f20b7c", + "f8720a5a-5a8b-423c-065f-8d3a3469fbca" + ], + "owner": "316251", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240" + }, { "id": "cfbf928f-56b8-9813-f8f3-4ac4e342d965", "name": "Register for challenges", @@ -46,6 +100,62 @@ "owner": "316251", "public": false, "requests": [ + { + "id": "0461a7de-3ae1-f873-b667-50d04a43b317", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/phases/1110005", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497959637871, + "name": "New logic, access denied", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] + }, + { + "id": "1af5c911-4627-ad92-085c-63e6fc7b6d9e", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/phases/1110005", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497959273575, + "name": "New logic, access denied", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] + }, { "id": "2af8f0d9-f3e8-c58a-ca3d-1130e4b07371", "headers": "Authorization: Bearer {{authToken}}\n", @@ -75,6 +185,62 @@ "responses": [], "folder": "712ffa63-a959-e4a3-6af9-84d4f236b2f3" }, + { + "id": "3246a996-e8f9-5e60-79b9-8aeffcd5392f", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/1110003", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497958076427, + "name": "Old logic, access denied", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] + }, + { + "id": "42b84596-9d5a-50e7-76be-c1ad23f98468", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/1110002", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497957969156, + "name": "Old logic, access allowed", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] + }, { "id": "46cf305a-8251-66aa-391c-46def82773a1", "headers": "Authorization: Bearer {{authToken}}\n", @@ -214,6 +380,34 @@ "rawModeData": "{\n \"username\": \"heffan\", \n \"password\": \"password\"\n}", "folder": "0eeb693c-c6b6-e23b-156d-cff5f21dbb27" }, + { + "id": "70b3453b-1d1a-e411-f8e5-527edb0a2530", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/registrants/1110002", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497934833132, + "name": "Old logic, access allowed", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] + }, { "id": "7c7643c6-89ab-641e-b67a-32b3ac91e09e", "headers": "Authorization: Bearer {{authToken}}\n", @@ -304,7 +498,7 @@ "folder": "712ffa63-a959-e4a3-6af9-84d4f236b2f3" }, { - "id": "d830ec36-eb8e-9586-c546-14af77cec152", + "id": "b3cb44e7-3e5f-897e-5d6f-6179afc52653", "headers": "Authorization: Bearer {{authToken}}\n", "headerData": [ { @@ -314,7 +508,7 @@ "enabled": true } ], - "url": "{{url}}/develop/challenges/checkpoint/2220002", + "url": "{{url}}/challenges/registrants/1110005", "queryParams": [], "preRequestScript": null, "pathVariables": {}, @@ -325,15 +519,45 @@ "tests": null, "currentHelper": "normal", "helperAttributes": {}, - "time": 1497550612717, - "name": "Old logic, access allowed", + "time": 1497935002619, + "name": "New logic, access denied", "description": "", "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] + }, + { + "id": "bcc821a7-0e3a-3454-d900-12af0cc94656", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/registrants/1110001", + "queryParams": [], + "pathVariables": {}, + "pathVariableData": [], + "preRequestScript": null, + "method": "GET", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "data": null, + "dataMode": "params", + "name": "No groups (challenge is not private)", + "description": "", + "descriptionFormat": "html", + "time": 1497934405019, + "version": 2, "responses": [], - "folder": "712ffa63-a959-e4a3-6af9-84d4f236b2f3" + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "folder": "6a038555-23cd-e79f-1d34-0fb860e305a3" }, { - "id": "f545bbfc-36d7-6567-25a8-b4d6634575e7", + "id": "bf83e2d2-549b-361e-f5cf-66a40d816f0c", "headers": "Authorization: Bearer {{authToken}}\n", "headerData": [ { @@ -343,7 +567,7 @@ "enabled": true } ], - "url": "{{url}}/develop/challenges/checkpoint/2220004", + "url": "{{url}}/challenges/1110004", "queryParams": [], "preRequestScript": null, "pathVariables": {}, @@ -354,12 +578,410 @@ "tests": null, "currentHelper": "normal", "helperAttributes": {}, - "time": 1497550705028, + "time": 1497958165136, + "name": "New logic, access allowed", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] + }, + { + "id": "c305f2ea-dbfd-f95f-c809-583133af5881", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/phases/1110004", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497959248881, "name": "New logic, access allowed", "description": "", "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] + }, + { + "id": "c383cab7-3145-145e-9da9-846001755460", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/1110001", + "queryParams": [], + "pathVariables": {}, + "pathVariableData": [], + "preRequestScript": null, + "method": "GET", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "data": null, + "dataMode": "params", + "name": "No groups (challenge is not private)", + "description": "", + "descriptionFormat": "html", + "time": 1497957874624, + "version": 2, "responses": [], - "folder": "712ffa63-a959-e4a3-6af9-84d4f236b2f3" + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "folder": "cada5a0c-766f-dde0-3c9f-d001a67eddd4" + }, + { + "id": "c7d11de6-630a-71bd-4095-cd3c8fb8ab77", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/phases/1110001", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "version": 2, + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497959147405, + "name": "No groups (challenge is not private)", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] + }, + { + "id": "d3e5ca45-334d-fb54-1fd7-46f8e7b82841", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/submissions/2220003", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497959455425, + "name": "Old logic, access denied", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] + }, + { + "id": "d7a050dc-6eaa-f62e-24e4-37d111002d4a", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/phases/1110003", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497959220837, + "name": "Old logic, access denied", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] + }, + { + "id": "d830ec36-eb8e-9586-c546-14af77cec152", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/develop/challenges/checkpoint/2220002", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497550612717, + "name": "Old logic, access allowed", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [], + "folder": "712ffa63-a959-e4a3-6af9-84d4f236b2f3" + }, + { + "id": "e97dac4e-c786-27b1-5e4b-fff50b6de93a", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/registrants/1110004", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497934940451, + "name": "New logic, access allowed", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] + }, + { + "id": "f545bbfc-36d7-6567-25a8-b4d6634575e7", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/develop/challenges/checkpoint/2220004", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497550705028, + "name": "New logic, access allowed", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [], + "folder": "712ffa63-a959-e4a3-6af9-84d4f236b2f3" + }, + { + "id": "f5da62a7-9231-5f7a-f44a-f2f14c9ae003", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/phases/1110002", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497959161340, + "name": "Old logic, access allowed", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] + }, + { + "id": "f73f4e00-c286-d440-ce79-89095d7354dd", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/registrants/1110003", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497934860473, + "name": "Old logic, access denied", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] + }, + { + "id": "f8720a5a-5a8b-423c-065f-8d3a3469fbca", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/submissions/2220005", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497959508749, + "name": "New logic, access denied", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] + }, + { + "id": "f8e9d38f-8d8d-6e63-4978-6e3546f20b7c", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/submissions/2220004", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497959483268, + "name": "New logic, access allowed", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] + }, + { + "id": "f90179ed-98da-be6d-77ae-9e3aa4199b5c", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/submissions/2220001", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "version": 2, + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497959423349, + "name": "No groups (challenge is not private)", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] + }, + { + "id": "f915c206-b3fe-a4be-1094-bc8a448cb467", + "headers": "Authorization: Bearer {{authToken}}\n", + "headerData": [ + { + "key": "Authorization", + "value": "Bearer {{authToken}}", + "description": "", + "enabled": true + } + ], + "url": "{{url}}/challenges/submissions/2220002", + "queryParams": [], + "preRequestScript": null, + "pathVariables": {}, + "pathVariableData": [], + "method": "GET", + "data": null, + "dataMode": "params", + "tests": null, + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1497959438513, + "name": "Old logic, access allowed", + "description": "", + "collectionId": "ba962be9-0d58-f187-8809-008a39bc2240", + "responses": [] }, { "id": "fd4cd936-2d4d-a272-f402-d0f7b6cab82f", From af2daa1edcc93390999e14bcedf8fa928d48590c Mon Sep 17 00:00:00 2001 From: Guiqiang Zhang Date: Tue, 20 Jun 2017 22:41:33 +0800 Subject: [PATCH 08/17] revert commit --- tc-api.iml | 9 - tc-api.ipr | 82 --------- tc-api.iws | 495 ----------------------------------------------------- 3 files changed, 586 deletions(-) delete mode 100644 tc-api.iml delete mode 100644 tc-api.ipr delete mode 100644 tc-api.iws diff --git a/tc-api.iml b/tc-api.iml deleted file mode 100644 index 44b943bfa..000000000 --- a/tc-api.iml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/tc-api.ipr b/tc-api.ipr deleted file mode 100644 index 92b3a0143..000000000 --- a/tc-api.ipr +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1.8 - - - - - - - - \ No newline at end of file diff --git a/tc-api.iws b/tc-api.iws deleted file mode 100644 index 16b05a466..000000000 --- a/tc-api.iws +++ /dev/null @@ -1,495 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - localhost - 5050 - - - - - - - - - - 1467168622962 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 57a54928729c10028d4ddbdf46e3c2c57eb7e540 Mon Sep 17 00:00:00 2001 From: ajefts Date: Tue, 20 Jun 2017 22:00:42 -0400 Subject: [PATCH 09/17] fixed issue with is_studio check --- actions/challengeRegistration.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/challengeRegistration.js b/actions/challengeRegistration.js index 9424951ef..149a40d96 100644 --- a/actions/challengeRegistration.js +++ b/actions/challengeRegistration.js @@ -897,7 +897,7 @@ exports.registerChallenge = { cb(); return; } - var isStudio = result[0].isStudio !== 0; + var isStudio = result[0].is_studio !== 0; api.challengeHelper.checkUserChallengeEligibility(connection, challengeId, function (err) { cb(err, isStudio); }); From d6c922d99d833282f52a35b8ee180d0ebb7e0f17 Mon Sep 17 00:00:00 2001 From: skyhit Date: Wed, 21 Jun 2017 10:36:47 +0800 Subject: [PATCH 10/17] More eligibility and group updates (#506) (#507) * Improve challenge visibility control (#501) * IMPROVE CHALLENGE VISIBILITY CONTROL (https://www.topcoder.com/challenge-details/30057891/?type=develop) Verification guide: docs/Verification_Guide-Improve Challenge Visibility Control.doc * Restoring an accidentially modified file * Fixed the case with a challenge that doesn't have eligibility * Shared the eligibility verification with challengeRegistration. The eligibility check routine is now in challengeHelper and can be added anywhere by a couple of simple lines of code. * improve the query * update query for groups (#502) * Update queries (#503) improve logging for v3 api call * should use externalToken field name * update queries for group checking * Improve challenge visibility control: getChallenge and getRegistrants (#504) * IMPROVE CHALLENGE VISIBILITY CONTROL (https://www.topcoder.com/challenge-details/30057891/?type=develop) Verification guide: docs/Verification_Guide-Improve Challenge Visibility Control.doc * Restoring an accidentially modified file * Fixed the case with a challenge that doesn't have eligibility * Shared the eligibility verification with challengeRegistration. The eligibility check routine is now in challengeHelper and can be added anywhere by a couple of simple lines of code. * Improve challenge visibility control: getChallenge and getRegistrants * revert commit From e8a0d71357e3496d784818cfaa1aaf241ae85fb7 Mon Sep 17 00:00:00 2001 From: Guiqiang Zhang Date: Tue, 25 Jul 2017 00:32:50 +0800 Subject: [PATCH 11/17] fix social provider id --- initializers/.dataAccess.js.swp | Bin 28672 -> 0 bytes initializers/helper.js | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 initializers/.dataAccess.js.swp diff --git a/initializers/.dataAccess.js.swp b/initializers/.dataAccess.js.swp deleted file mode 100644 index 542d73f7eba4b7e4272e91f9d0283b665d384cbe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 28672 zcmeI54UAmXb;lnekUBshp_C>S;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.js b/initializers/helper.js index e9961b888..b4ca38b54 100755 --- a/initializers/helper.js +++ b/initializers/helper.js @@ -1272,7 +1272,7 @@ helper.getProviderId = function (provider, callback) { if (provider.startsWith("ad") || provider.startsWith("auth0")) { providerId = helper.socialProviders.ad; } - if (provider.startsWith("samlp")) { + if (provider.startsWith("samlp") || provider.startsWith("adfs")) { providerId = helper.socialProviders.samlp; } if (providerId) { From a2820eef03d3f6e2eea56a702d1c6ba285156f90 Mon Sep 17 00:00:00 2001 From: Guiqiang Zhang Date: Tue, 25 Jul 2017 09:38:07 +0800 Subject: [PATCH 12/17] check v3 token expiration --- initializers/v3client.js | 3 ++- package.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/initializers/v3client.js b/initializers/v3client.js index df8312a37..b1e620288 100644 --- a/initializers/v3client.js +++ b/initializers/v3client.js @@ -12,6 +12,7 @@ var request = require('request'); var _ = require('underscore'); var async = require('async'); +var tcAccounts = require('tc-accounts'); /** * The URL of the V3 API @@ -63,7 +64,7 @@ function getToken(connection, callback) { return; } // Cached token - if (!_.isUndefined(tokens[connection.authToken])) { + if (!_.isUndefined(tokens[connection.authToken]) && !tcAccounts.isTokenExpired(tokens[connection.authToken])) { callback(null, tokens[connection.authToken]); return; } diff --git a/package.json b/package.json index c3e6dfc2a..84605d1dd 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,8 @@ "validator": "~3.5.0", "wkhtmltoimage": ">= 0.1.3", "xml2js": "0.2.x", - "xtend": "2.1.x" + "xtend": "2.1.x", + "tc-accounts": "https://github.com/appirio-tech/accounts-app#dev" }, "devDependencies": { "supertest": "0.8.x", From 650f8b8dcba19f0f31f80e74ef25533191cf430f Mon Sep 17 00:00:00 2001 From: Guiqiang Zhang Date: Tue, 25 Jul 2017 09:57:46 +0800 Subject: [PATCH 13/17] copy over token exipiration check logic --- initializers/v3client.js | 65 ++++++++++++++++++++++++++++++++++++++-- package.json | 3 +- 2 files changed, 64 insertions(+), 4 deletions(-) diff --git a/initializers/v3client.js b/initializers/v3client.js index b1e620288..c9b389aeb 100644 --- a/initializers/v3client.js +++ b/initializers/v3client.js @@ -12,7 +12,6 @@ var request = require('request'); var _ = require('underscore'); var async = require('async'); -var tcAccounts = require('tc-accounts'); /** * The URL of the V3 API @@ -64,7 +63,7 @@ function getToken(connection, callback) { return; } // Cached token - if (!_.isUndefined(tokens[connection.authToken]) && !tcAccounts.isTokenExpired(tokens[connection.authToken])) { + if (!_.isUndefined(tokens[connection.authToken]) && !isTokenExpired(tokens[connection.authToken])) { callback(null, tokens[connection.authToken]); return; } @@ -87,6 +86,68 @@ function getToken(connection, callback) { }); } + +function urlBase64Decode(str) { + var output = str.replace(/-/g, '+').replace(/_/g, '/'); + + switch (output.length % 4) { + case 0: + break; + + case 2: + output += '=='; + break; + + case 3: + output += '='; + break; + + default: + throw 'Illegal base64url string!' + } + return decodeURIComponent(escape(atob(output)));//polyfill https://github.com/davidchambers/Base64.js +} + +function decodeToken(token) { + var parts = token.split('.'); + + if (parts.length !== 3) { + throw new Error('The token is invalid') + } + + var decoded = urlBase64Decode(parts[1]); + + if (!decoded) { + throw new Error('Cannot decode the token') + } + + return JSON.parse(decoded) +} + +function getTokenExpirationDate(token) { + var decoded = decodeToken(token); + + if(typeof decoded.exp === 'undefined') { + return null + } + + var d = new Date(0);// The 0 here is the key, which sets the date to the epoch + d.setUTCSeconds(decoded.exp); + + return d +} + +function isTokenExpired(token) { + var d = getTokenExpirationDate(token); + + if (d === null) { + return false + } + + // Token expired? + return !(d.valueOf() > (new Date().valueOf())) +} + /** * Get IDs of users in the specified group * diff --git a/package.json b/package.json index 84605d1dd..c3e6dfc2a 100644 --- a/package.json +++ b/package.json @@ -48,8 +48,7 @@ "validator": "~3.5.0", "wkhtmltoimage": ">= 0.1.3", "xml2js": "0.2.x", - "xtend": "2.1.x", - "tc-accounts": "https://github.com/appirio-tech/accounts-app#dev" + "xtend": "2.1.x" }, "devDependencies": { "supertest": "0.8.x", From 15c7f74998ddb672f0f8358c16f65213f1691dff Mon Sep 17 00:00:00 2001 From: Guiqiang Zhang Date: Tue, 25 Jul 2017 10:28:29 +0800 Subject: [PATCH 14/17] add atob --- initializers/v3client.js | 1 + package.json | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/initializers/v3client.js b/initializers/v3client.js index c9b389aeb..765fc2a0e 100644 --- a/initializers/v3client.js +++ b/initializers/v3client.js @@ -12,6 +12,7 @@ var request = require('request'); var _ = require('underscore'); var async = require('async'); +var atob = require('atob'); /** * The URL of the V3 API diff --git a/package.json b/package.json index c3e6dfc2a..d5470d6df 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,8 @@ "validator": "~3.5.0", "wkhtmltoimage": ">= 0.1.3", "xml2js": "0.2.x", - "xtend": "2.1.x" + "xtend": "2.1.x", + "atob": "2.0.3" }, "devDependencies": { "supertest": "0.8.x", From 8d6f97f1d603275b767adafed45622762cee20f0 Mon Sep 17 00:00:00 2001 From: ajefts Date: Mon, 2 Oct 2017 11:22:21 -0400 Subject: [PATCH 15/17] updating activation URL --- actions/user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/user.js b/actions/user.js index 88bece40f..b8f7101f9 100644 --- a/actions/user.js +++ b/actions/user.js @@ -233,7 +233,7 @@ function userActivationEmail(api, connection, next) { toAddress : rs[0].address, fromAddress : process.env.TC_EMAIL_ACCOUNT, senderName : activationEmailSenderName, - url : process.env.TC_ACTIVATION_SERVER_NAME + '/reg2/activate.action?code=' + activationCode, + url : process.env.TC_ACTIVATION_SERVER_NAME + '?code=' + activationCode + '&retUrl=https://www.topcoder.com/skill-picker', userHandle : rs[0].handle }, 'default'); api.cache.save(cacheKey, currentResendTimes + 1, api.config.tcConfig.userActivationCacheLifeTime, From 7507828dd087e39b482393127456b1b3d88417af Mon Sep 17 00:00:00 2001 From: ajefts Date: Mon, 2 Oct 2017 11:23:29 -0400 Subject: [PATCH 16/17] updated activation URL --- actions/memberRegistration.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/memberRegistration.js b/actions/memberRegistration.js index cb75d89cf..789bcb61f 100644 --- a/actions/memberRegistration.js +++ b/actions/memberRegistration.js @@ -396,7 +396,7 @@ var registerUser = function (user, api, dbConnectionMap, next) { }, function (callback) { var url; - url = process.env.TC_ACTIVATION_SERVER_NAME + '/reg2/activate.action?code=' + activationCode; + url = process.env.TC_ACTIVATION_SERVER_NAME + '?code=' + activationCode + '&retUrl=https://www.topcoder.com/skill-picker'; if (user.regSource && user.regSource.match(/arena/)) { url += '&destination=http%3A%2F%2Farena.topcoder.com'; } From 61b025c87b06c54250e1a37605d1bdb85fff6c30 Mon Sep 17 00:00:00 2001 From: TonyJ Date: Mon, 2 Oct 2017 11:32:43 -0400 Subject: [PATCH 17/17] update activation url --- actions/challengeRegistration.js | 2 +- deploy/ci.sh | 3 ++- deploy/development.sh | 3 ++- deploy/vm.sh | 3 ++- local/env.sh | 3 ++- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/actions/challengeRegistration.js b/actions/challengeRegistration.js index 149a40d96..0d558f628 100644 --- a/actions/challengeRegistration.js +++ b/actions/challengeRegistration.js @@ -404,7 +404,7 @@ var sendNotificationEmail = function (api, componentInfo, userId, activeForumCat if (challengeType === CHALLENGE_TYPE.DEVELOP) { forumURL = api.config.tcConfig.developForumsUrlPrefix + activeForumCategoryId; reviewURL = process.env.TC_SOFTWARE_SERVER_NAME + '/review/actions/ViewProjectDetails?pid=' + challengeId; - submitURL = process.env.TC_ACTIVATION_SERVER_NAME + '/challenge-details/' + challengeId + '/submit/?type=develop'; + submitURL = process.env.TC_WWW_SERVER_NAME + '/challenge-details/' + challengeId + '/submit/?type=develop'; } else if (challengeType === CHALLENGE_TYPE.DESIGN) { forumURL = api.config.tcConfig.studioForumsUrlPrefix + activeForumCategoryId; //submitURL = process.env.TC_STUDIO_SERVER_NAME + '/?module=ViewContestDetails&ct=' + challengeId; diff --git a/deploy/ci.sh b/deploy/ci.sh index a0143cf31..e3cfb2f49 100644 --- a/deploy/ci.sh +++ b/deploy/ci.sh @@ -58,7 +58,8 @@ export TC_EMAIL_PASSWORD=tc_public_email export TC_EMAIL_FROM=tc.ldap.test@gmail.com export TC_EMAIL_TEMPLATE_DIR=mail_templates -export TC_ACTIVATION_SERVER_NAME="https://www.topcoder.com" +export TC_ACTIVATION_SERVER_NAME="https://api.topcoder.com/pub/activation.html" +export TC_WWW_SERVER_NAME="https://www.topcoder.com" export TC_SOFTWARE_SERVER_NAME="https://www.topcoder.com" #export DISABLE_CONSOLE_LOG=true diff --git a/deploy/development.sh b/deploy/development.sh index 11f08580c..7ec784d66 100755 --- a/deploy/development.sh +++ b/deploy/development.sh @@ -60,7 +60,8 @@ export TC_EMAIL_PASSWORD=tc_public_email export TC_EMAIL_FROM=tc.ldap.test.1@gmail.com export TC_EMAIL_TEMPLATE_DIR=mail_templates -export TC_ACTIVATION_SERVER_NAME="https://www.topcoder.com" +export TC_ACTIVATION_SERVER_NAME="https://api.topcoder.com/pub/activation.html" +export TC_WWW_SERVER_NAME="https://www.topcoder.com" export TC_SOFTWARE_SERVER_NAME="https://software.topcoder.com" export TC_FORUMS_SERVER_NAME="http://apps.topcoder.com/forums" diff --git a/deploy/vm.sh b/deploy/vm.sh index 5f75cefe6..a193827d3 100644 --- a/deploy/vm.sh +++ b/deploy/vm.sh @@ -54,7 +54,8 @@ export TC_EMAIL_PASSWORD=tc_public_email export TC_EMAIL_FROM=tc.ldap.test.1@gmail.com export TC_EMAIL_TEMPLATE_DIR=mail_templates -export TC_ACTIVATION_SERVER_NAME="https://www.topcoder.com" +export TC_ACTIVATION_SERVER_NAME="https://api.topcoder.com/pub/activation.html" +export TC_WWW_SERVER_NAME="https://www.topcoder.com" export TC_SOFTWARE_SERVER_NAME="https://software.topcoder.com" export TC_FORUMS_SERVER_NAME="http://apps.topcoder.com/forums" diff --git a/local/env.sh b/local/env.sh index ac4e6ab9c..2c2556c28 100644 --- a/local/env.sh +++ b/local/env.sh @@ -58,7 +58,8 @@ export TC_EMAIL_PASSWORD=tc_public_email export TC_EMAIL_FROM=tc.ldap.test.1@gmail.com export TC_EMAIL_TEMPLATE_DIR=mail_templates -export TC_ACTIVATION_SERVER_NAME="https://www.topcoder.com" +export TC_ACTIVATION_SERVER_NAME="https://api.topcoder.com/pub/activation.html" +export TC_WWW_SERVER_NAME="https://www.topcoder.com" export TC_SOFTWARE_SERVER_NAME="https://software.topcoder.com" export TC_FORUMS_SERVER_NAME="http://apps.topcoder.com/forums"