var express = require('express');
var router = express.Router();

import encryptUtils from '../utilities/encrypt';
import userUtils from '../utilities/users_service.js';

import { userAuth, adminAuth } from '../utilities/auth';

router.post('/', (req, res) => {
    const { first_name, last_name, email, username, password } = req.body;

    encryptUtils.encryptPassword(password).then((hashedPassword) => {
        const newUser = { first_name, last_name, email, username, password: hashedPassword };

        userUtils.createUser(newUser).then((createdUser) => {
            res.json(createdUser);
        }, () => res.sendStatus(400));
    }, () => res.sendStatus(500));
});

router.get('/', adminAuth, (req, res) => {
  userUtils.getUsers().then((users) => {
      res.json(users);
  }, () => res.sendStatus(404));
});

router.get('/:id', adminAuth, (req, res) => {
    const userID = req.params.id;

    userUtils.getUser(userID).then((user) => {
        res.json(user);
    }, () => res.sendStatus(404));
});

module.exports = router;

@@ -550,32 +550,143 @@
 eatedUser) =%3E %7B%0A
+            req.session.username = createdUser.username;%0A            req.session.status = createdUser.status;%0A%0A
             res.
@@ -700,24 +700,24 @@
 eatedUser);%0A
-
         %7D, (
@@ -826,16 +826,18 @@
 s) =%3E %7B%0A
+  
   userUt
@@ -871,24 +871,26 @@
  =%3E %7B%0A      
+  
 res.json(use
@@ -894,16 +894,18 @@
 users);%0A
+  
   %7D, () 

Add user to session when they create a new account