<commit_before>/**
 * PendingUserController
 *
 * @description :: Server-side logic for managing pendingusers
 * @help        :: See http://sailsjs.org/#!/documentation/concepts/Controllers
 */

const uuid = require('node-uuid');

module.exports = {

  create: function(req, res) {

    var host = "http://127.0.0.1:4200";
    var user = req.body.data.attributes;
    user.id = uuid.v4();
    user["isAdmin"] = false;
    var to =  user.email;
    var subject = 'Nanocloud - Verify your email address';
    var message = 'Hello ' + user["first-name"] + ' ' + user["last-name"] + ',<br> please verify your email address by clicking this link: '+
        '<a href="'+host+'/#/activate/'+user.id+'">Activate my account</a>';

    EmailService.sendMail(to, subject, message)
      .then(() => {
        return PendingUser.create(JsonApiService.deserialize(user))
      })
      .then((created_user) => {
        res.status(201);
        return res.json(JsonApiService.serialize("PendingUser", created_user));
      })
      .catch(() => {
          return res.send(500, "Could not signup");
      });
  },

  update: function(req, res) {
    let pendingUserID = req.params.id;
    PendingUser.findOne({
      "id": pendingUserID
    })
    .then((user) => {
      if (!user) {
        return res.notFound('No user has been found');
      }
      sails.log('Found "%s"', user.firstName);

      User.create(user)
      .then(() => {
        return PendingUser.destroy({
          "id": pendingUserID
        });
      })
      .then(() => {
        return res.json(user);
      });<commit_msg>remove log<commit_after>/**
 * PendingUserController
 *
 * @description :: Server-side logic for managing pendingusers
 * @help        :: See http://sailsjs.org/#!/documentation/concepts/Controllers
 */

const uuid = require('node-uuid');

module.exports = {

  create: function(req, res) {

    var host = "http://127.0.0.1:4200";
    var user = req.body.data.attributes;
    user.id = uuid.v4();
    user["isAdmin"] = false;
    var to =  user.email;
    var subject = 'Nanocloud - Verify your email address';
    var message = 'Hello ' + user["first-name"] + ' ' + user["last-name"] + ',<br> please verify your email address by clicking this link: '+
        '<a href="'+host+'/#/activate/'+user.id+'">Activate my account</a>';

    EmailService.sendMail(to, subject, message)
      .then(() => {
        return PendingUser.create(JsonApiService.deserialize(user))
      })
      .then((created_user) => {
        res.status(201);
        return res.json(JsonApiService.serialize("PendingUser", created_user));
      })
      .catch(() => {
        return res.send(500, "Could not signup");
      });
  },

  update: function(req, res) {
    let pendingUserID = req.params.id;
    PendingUser.findOne({
      "id": pendingUserID
    })
    .then((user) => {
      if (!user) {
        return res.notFound('No user has been found');
      }
      User.create(user)
      .then(() => {
        return PendingUser.destroy({
          "id": pendingUserID
        });
      })
      .then(() => {
        return res.json(user);
      });
{'fraction_non_alphanumeric': 0.17130963816842779, 'fraction_numerical': 0.010886967659301952, 'mean_word_length': 2.4788418708240534, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7307004', 'n_tokens_mistral': 1004, 'n_tokens_neox': 982, 'n_words': 206}