<commit_before>const auth = require('express').Router()
const users = require('../../model/users')

auth.get('/', (request, response) => {
  if(!request.session.user){
    response.render('splash', {user: null})
  } else if (request.session.user) {
    users.findUserById(request.session.user.id)
    .then((user) => {
      response.render('splash', {user: user})
    })
  }
})

auth.get('/login', (request, response) => {
  if(!request.session.user){
    response.render('login', {user: null, message: ''})
  } else if (request.session.user) {
    response.redirect('/')
  }
})

auth.post('/login', (request, response) => {
  const {email, password} = request.body;
   users.logInUser(email, password)
    .then((user) => {
      if(user){
        request.session.user = user;
        response.redirect(`/user/${user.id}`)
      } else if(user === undefined) {
        response.render('login', {user: null, message: 'Incorrect email or password.'})
      }
    })
})

auth.get('/signup', (request, response) => {
  response.render('signup', {user: null, message: ''})<commit_msg>logging in directs to splash page instead of profile<commit_after>const auth = require('express').Router()
const users = require('../../model/users')

auth.get('/', (request, response) => {
  if(!request.session.user){
    response.render('splash', {user: null})
  } else if (request.session.user) {
    users.findUserById(request.session.user.id)
    .then((user) => {
      response.render('splash', {user: user})
    })
  }
})

auth.get('/login', (request, response) => {
  if(!request.session.user){
    response.render('login', {user: null, message: ''})
  } else if (request.session.user) {
    response.redirect('/')
  }
})

auth.post('/login', (request, response) => {
  const {email, password} = request.body;
   users.logInUser(email, password)
    .then((user) => {
      if(user){
        request.session.user = user;
        response.redirect('/')
      } else if(user === undefined) {
        response.render('login', {user: null, message: 'Incorrect email or password.'})
      }
    })
})

auth.get('/signup', (request, response) => {
  response.render('signup', {user: null, message: ''})
{'fraction_non_alphanumeric': 0.20539798719121682, 'fraction_numerical': 0.0, 'mean_word_length': 3.382765531062124, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '1043429', 'n_tokens_mistral': 700, 'n_tokens_neox': 698, 'n_words': 138}