<commit_before>import formidable from 'formidable'
import _ from 'lodash'

import { Group, GroupSerializer, User } from '../../../models'
import exceptions  from '../../../support/exceptions'


export default class GroupsController {
  static async create(req, res) {
    if (!req.user)
      return res.status(401).jsonp({ err: 'Not found', status: 'fail'})

    var params = {
      username: req.body.group.username,
      screenName: req.body.group.screenName,
      isPrivate: req.body.group.isPrivate
    }

    try {
      var group = new Group(params)
      await group.create(req.user.id, false)

      var json = await new GroupSerializer(group).promiseToJSON()
      res.jsonp(json)
    } catch(e) {
      exceptions.reportError(res)(e)
    }
  }

  static async sudoCreate(req, res) {<commit_msg>Update request validation on croup-create<commit_after>import formidable from 'formidable'
import _ from 'lodash'

import { Group, GroupSerializer, User } from '../../../models'
import exceptions  from '../../../support/exceptions'


export default class GroupsController {
  static async create(req, res) {
    if (!req.user)
      return res.status(401).jsonp({ err: 'Unauthorized', status: 'fail'})

    if (!req.body.group)
      return res.status(400).jsonp({ err: 'Malformed request', status: 'fail'})

    var params = {
      username: req.body.group.username,
      screenName: req.body.group.screenName,
      isPrivate: req.body.group.isPrivate
    }

    try {
      var group = new Group(params)
      await group.create(req.user.id, false)

      var json = await new GroupSerializer(group).promiseToJSON()
      res.jsonp(json)
    } catch(e) {
      exceptions.reportError(res)(e)
    }
  }

  static async sudoCreate(req, res) {
{'fraction_non_alphanumeric': 0.1363377067883628, 'fraction_numerical': 0.00513405590416429, 'mean_word_length': 2.9773242630385486, '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': '5281121', 'n_tokens_mistral': 556, 'n_tokens_neox': 534, 'n_words': 136}