|
@@ -10,14 +10,14 @@ router.get('/', function(req, res, next) {
|
|
|
});
|
|
|
|
|
|
|
|
|
-/* GET users listing. */
|
|
|
+/* post users login. */
|
|
|
router.post('/login', function(req, res, next) {
|
|
|
const params = {...req.body};
|
|
|
const {
|
|
|
username,
|
|
|
password
|
|
|
} = params;
|
|
|
-
|
|
|
+ console.log(username);
|
|
|
Users.login({username, password}).
|
|
|
then((user) => res.send(user)).
|
|
|
catch((e) => {
|
|
@@ -27,4 +27,21 @@ router.post('/login', function(req, res, next) {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+/* post users register. */
|
|
|
+router.post('/register', function(req, res, next) {
|
|
|
+ const params = {...req.body};
|
|
|
+ const {
|
|
|
+ username,
|
|
|
+ password
|
|
|
+ } = params;
|
|
|
+ console.log(username);
|
|
|
+ Users.register({username, password}).
|
|
|
+ then((user) => res.send(user)).
|
|
|
+ catch((e) => {
|
|
|
+ console.log(e);
|
|
|
+ res.status(400);
|
|
|
+ res.send(JSONError("Bad Credentials"));
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
module.exports = router;
|