<commit_before>// These methods handle the User-related routes.

import deepcopy       from 'deepcopy';
import Config         from '../Config';
import ClassesRouter  from './ClassesRouter';
import PromiseRouter  from '../PromiseRouter';
import rest           from '../rest';
import Auth           from '../Auth';
import passwordCrypto from '../password';
import RestWrite      from '../RestWrite';
let cryptoUtils = require('../cryptoUtils');
let triggers = require('../triggers');
let verifyUtil = require('../vendor/verifyUtil');


export class UsersRouter extends ClassesRouter {
  handleFind(req) {
    req.params.className = '_User';
    return super.handleFind(req);
  }

  handleGet(req) {
    if (req.params.objectId === 'me') {
      return this.handleMe(req);
    }
    req.params.className = '_User';
    return super.handleGet(req);
  }

  handleCreate(req) {
    let data = deepcopy(req.body);
    if(data.email){
      return verifyUtil.getVerifyEmail(data.email).then((result)=>{
        if(result){
          // Check for email uniqueness
          req.body = data;
          req.params.className = '_User';
          return super.handleCreate(req);
        }else{
          throw new Parse.Error(Parse.Error.INVALID_EMAIL_ADDRESS,
              'Email address format is invalid.');
        }
      })
    }else{
      req.body = data;
      req.params.className = '_User';

      return super.handleCreate(req);
    }
  }

  handleUpdate(req) {
    req.params.className = '_User';
    return super.handleUpdate(req);
  }

  handleDelete(req) {
    req.params.className = '_User';
    return super.handleDelete(req);<commit_msg>[PinParse] mailgunkey<commit_after>// These methods handle the User-related routes.

import deepcopy       from 'deepcopy';
import Config         from '../Config';
import ClassesRouter  from './ClassesRouter';
import PromiseRouter  from '../PromiseRouter';
import rest           from '../rest';
import Auth           from '../Auth';
import passwordCrypto from '../password';
import RestWrite      from '../RestWrite';
let cryptoUtils = require('../cryptoUtils');
let triggers = require('../triggers');
let verifyUtil = require('../vendor/verifyUtil');


export class UsersRouter extends ClassesRouter {
  handleFind(req) {
    req.params.className = '_User';
    return super.handleFind(req);
  }

  handleGet(req) {
    if (req.params.objectId === 'me') {
      return this.handleMe(req);
    }
    req.params.className = '_User';
    return super.handleGet(req);
  }

  handleCreate(req) {
    let data = deepcopy(req.body);
    if(data.email){
      let publicKey=req.config.mailgunApiKey;
      return verifyUtil.getVerifyEmail(data.email,publicKey).then((result)=>{
        if(result){
          // Check for email uniqueness
          req.body = data;
          req.params.className = '_User';
          return super.handleCreate(req);
        }else{
          throw new Parse.Error(Parse.Error.INVALID_EMAIL_ADDRESS,
              'Email address format is invalid.');
        }
      })
    }else{
      req.body = data;
      req.params.className = '_User';

      return super.handleCreate(req);
    }
  }

  handleUpdate(req) {
    req.params.className = '_User';
    return super.handleUpdate(req);
  }

  handleDelete(req) {
    req.params.className = '_User';
    return super.handleDelete(req);
{'fraction_non_alphanumeric': 0.1351431980906921, 'fraction_numerical': 0.0, 'mean_word_length': 2.6366594360086766, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3190314', 'n_tokens_mistral': 961, 'n_tokens_neox': 941, 'n_words': 226}