<commit_before>var db = require('../db.js');


module.exports = {

  getUser: function(req, res) {
    console.log('GET USER REQ: ', req);
    db.User.findOne({
      where: { email: String(req.params.email) }
    })
    .then(function(user) {
      res.status(200).json(user);
    });
  },

  postUser: function(req, res) {
    db.User.findOrCreate({where: {email: req.body.email},
      defaults: {username: req.body.username, image: req.body.image}
    }).spread(function(user, created) {
      console.log(user.get({
        plain: true
      }));
      console.log(created);
    }).then(function(user) {
      res.status(201).json(user);
    });
    // var params = {
    //   username: req.body.username,
    //   email: req.body.email,
    //   image: req.body.image
    // }

    // db.User.create(params)
    // .then(function(user) {
    //   res.status(201).json(user);
    // })
  }
};<commit_msg>modified user-controller to attempt to get user id and added post req for joining event<commit_after>var db = require('../db.js');


module.exports = {

  getUser: function(req, res) {
    console.log('GET USER REQ**: ', req.body);
    db.User.findAll({
      where: { email: req.body.email }
    })
    .then(function(user) {
      console.log('User Get req:', user);
      // return {
      //   id: user
      // };
      res.status(200).json(user);
    });
  },

  postUser: function(req, res) {
    db.User.findOrCreate({where: {email: req.body.email},
      defaults: {username: req.body.username, image: req.body.image}
    })
    .spread(function(user, created) {
      console.log(user.get({
        plain: true
      }));
      console.log(created);
    })
    .then(function(user) {
      res.status(201).json(user);
    });
  },

  postJoinEvent: function(req, res) {
    db.EventParticipant.findOrCreate({where:
      {EventId: req.body.EventId},
      include: [{UserId: req.body.UserId}]
    })
    .spread(function(user, created) {
      console.log(user.get({
        plain: true
      }));
      console.log(created);
    }).then(function(user) {
      res.status(201).json(user);
    });
  },
};
{'fraction_non_alphanumeric': 0.18464437117286858, 'fraction_numerical': 0.008478568064060292, 'mean_word_length': 2.3448818897637795, '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': '5510042', 'n_tokens_mistral': 743, 'n_tokens_neox': 723, 'n_words': 121}