<commit_before>// api/policies/hasSprintAdmin.js

/**
 * Policy to check if user has admin rights to sprint in specified project or not. Actual check is
 * done by one of following internal AuthService methods;
 *
 *  - hasSprintAdmin
 *  - hasProjectAdmin
 *
 * Note that this policy relies one of following parameters are:
 *
 *  - id
 *  - sprintId
 *  - projectId
 *
 * Actual auth checks are done depending of given parameters.
 *
 * @param   {Request}   request     Request object
 * @param   {Response}  response    Response object
 * @param   {Function}  next        Callback function to call if all is ok
 */
module.exports = function hasSprintAdmin(request, response, next) {
    sails.log.verbose(" POLICY - api/policies/hasSprintAdmin.js");

    var id = parseInt(request.param("id"), 10);
    var sprintId = parseInt(request.param("sprintId"), 10);
    var projectId = parseInt(request.param("projectId"), 10);

    // Id or sprint id given
    if (!isNaN(id) || !isNaN(sprintId)) {
        sprintId = !isNaN(sprintId) ? id : sprintId;

        AuthService.hasSprintAdmin(request.user, sprintId, function(error, hasRight) {
            if (error) { // Error occurred<commit_msg>Fixed logic error from policy.<commit_after>// api/policies/hasSprintAdmin.js

/**
 * Policy to check if user has admin rights to sprint in specified project or not. Actual check is
 * done by one of following internal AuthService methods;
 *
 *  - hasSprintAdmin
 *  - hasProjectAdmin
 *
 * Note that this policy relies one of following parameters are:
 *
 *  - id
 *  - sprintId
 *  - projectId
 *
 * Actual auth checks are done depending of given parameters.
 *
 * @param   {Request}   request     Request object
 * @param   {Response}  response    Response object
 * @param   {Function}  next        Callback function to call if all is ok
 */
module.exports = function hasSprintAdmin(request, response, next) {
    sails.log.verbose(" POLICY - api/policies/hasSprintAdmin.js");

    var id = parseInt(request.param("id"), 10);
    var sprintId = parseInt(request.param("sprintId"), 10);
    var projectId = parseInt(request.param("projectId"), 10);

    // Id or sprint id given
    if (!isNaN(id) || !isNaN(sprintId)) {
        sprintId = !isNaN(sprintId) ? sprintId : id;

        AuthService.hasSprintAdmin(request.user, sprintId, function(error, hasRight) {
            if (error) { // Error occurred
{'fraction_non_alphanumeric': 0.10879533138807837, 'fraction_numerical': 0.005002084201750729, 'mean_word_length': 3.181184668989547, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6620724', 'n_tokens_mistral': 721, 'n_tokens_neox': 708, 'n_words': 229}