<commit_before>// =====================

var express = require("express");
var passport = require("../config/passport");
var router = express.Router();
// grabbing our models
var db = require("../models");
var request = require("request")
// Requiring our custom middleware for checking if a user is logged in
var isAuthenticated = require("../config/middleware/isAuthenticated");

// ROUTES //////////////////////////////////////


// ==============  SIGN UP ================================
router.get("/signup", function(req, res) {
  // send us to the next get function instead.
  res.render("signup");
});



// ===========  Login page =================================
router.get("/login", function(req, res) {
    res.render("login", "");
    if (req.user){
      res.redirect("/members");
    }
});

router.get("/members", function(req, res) {
    res.render("members", "");
});


 // =====Route for logging user out============================

  router.get("/logout", function(req, res) {
    req.logout();
    res.redirect("/");
  });

  router.get("/members", isAuthenticated, function(req, res) {
    if (req.user) {
      res.redirect("/members");
    }
  });

// ====Route for getting some data about our user to be used client side========

  router.get("/api/user_data", function(req, res) {
    if (!req.user) {
      // The user is not logged in, send back an empty object
      res.json({});
    }
    else {
      // Otherwise send back the user's email and id
      // Sending back a password, even a hashed password, isn't a good idea
      res.json({
        email: req.user.email,
        id: req.user.id
      });
    }
  });

  //=====================Sign Up Post Route ================================
  router.post("/signup", function(req, res) {
    console.log(req.body);
    db.User.create({
      email: req.body.email,
      password: <PASSWORD>
    }).then(function() {
      res.redirect("/login");
    }).catch(function(err) {
      console.log(err);
    });
  });

 router.post("/login", passport.authenticate("local"), function(req, res) {
    // Since we're doing a POST with javascript, we can't actually redirect that post into a GET request
    // So we're sending the user back the route to the members page because the redirect will happen on the front end
    // They won't get this or even be able to access this page if they aren't authed
    res.redirect("/members");
  });
 

// ==========  render Create Subject ===========
router.get("/create-subject", function(req, res) {
  // send us to the next get function instead.
  res.render("create-subject");<commit_msg>Minor change to controller.js<commit_after>// =====================

var express = require("express");
var passport = require("../config/passport");
var router = express.Router();
// grabbing our models
var db = require("../models");
var request = require("request")
// Requiring our custom middleware for checking if a user is logged in
var isAuthenticated = require("../config/middleware/isAuthenticated");

// ROUTES //////////////////////////////////////


// ==============  SIGN UP ================================
router.get("/signup", function(req, res) {
  // send us to the next get function instead.
  res.render("signup");
});



// ===========  Login page =================================
router.get("/login", function(req, res) {
    res.render("login", "");
    if (req.user){
      res.redirect("/members");
    }
});

router.get("/members", function(req, res) {
    res.render("members", "");
});


 // =====Route for logging user out============================

  router.get("/logout", function(req, res) {
    req.logout();
    res.redirect("/");
  });

  router.get("/members", isAuthenticated, function(req, res) {
    if (req.user) {
      res.redirect("/members");
    }
  });

// ====Route for getting some data about our user to be used client side========

  router.get("/api/user_data", function(req, res) {
    if (!req.user) {
      // The user is not logged in, send back an empty object
      res.json({});
    }
    else {
      // Otherwise send back the user's email and id
      // Sending back a password, even a hashed password, isn't a good idea
      res.json({
        email: req.user.email,
        id: req.user.id
      });
    }
  });

  //=====================Sign Up Post Route ================================
  router.post("/signup", function(req, res) {
    console.log(req.body);
    db.User.create({
      email: req.body.email,
      password: <PASSWORD>
    }).then(function() {
      res.redirect(307,"/login");
    }).catch(function(err) {
      console.log(err);
    });
  });

 router.post("/login", passport.authenticate("local"), function(req, res) {
    // Since we're doing a POST with javascript, we can't actually redirect that post into a GET request
    // So we're sending the user back the route to the members page because the redirect will happen on the front end
    // They won't get this or even be able to access this page if they aren't authed
    res.redirect("/members");
  });
 

// ==========  render Create Subject ===========
router.get("/create-subject", function(req, res) {
  // send us to the next get function instead.
  res.render("create-subject");
{'fraction_non_alphanumeric': 0.24143183549124142, 'fraction_numerical': 0.0005712109672505713, 'mean_word_length': 3.0007616146230007, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6480646', 'n_tokens_mistral': 1520, 'n_tokens_neox': 1447, 'n_words': 454}