From 218b2c014b1ab68ee8289210820d7b6b742bceef Mon Sep 17 00:00:00 2001 From: nanalelfe Date: Fri, 22 Jul 2016 23:58:19 -0400 Subject: Populated user info into user_profile.hbs --- app.js | 2 + routes/user.js | 8 ++-- views/user_profile_alt.hbs | 97 +++++++++++++++++++++------------------------- 3 files changed, 49 insertions(+), 58 deletions(-) diff --git a/app.js b/app.js index 7421fcf..4f398a9 100644 --- a/app.js +++ b/app.js @@ -54,6 +54,8 @@ app.use(express.static(__dirname)); app.use(function(req, res, next) { res.locals.login = req.isAuthenticated(); // global variable res.locals.session = req.session; + res.locals.user = req.user; + console.log(res.locals.user); next(); }); diff --git a/routes/user.js b/routes/user.js index 840930a..014a7d2 100644 --- a/routes/user.js +++ b/routes/user.js @@ -49,10 +49,11 @@ router.post('/signup', loggedOut, function(req, res, next) { req.check('password', "Password should be between 6 and 12 characters.") .notEmpty().withMessage('Password required').isLength({min: 6, max: 12}); req.check('password', "The confirmation password doesn't match.").equals(req.body.confirmPassword); + + // phone number optional if (req.body.phone_num){ req.check('phone_num', 'Please enter a valid phone number').isMobilePhone('en-CA'); } - // password has to be at least 4 characters long var errors = req.validationErrors(); if (errors) { @@ -68,14 +69,11 @@ router.post('/signup', loggedOut, function(req, res, next) { })(req, res); } - //res.redirect('/signup'); - }); router.post('/signin', loggedOut, function(req, res, next) { req.check('usrname', 'Username field is empty.').notEmpty(); req.check('password', "Password field is empty.").notEmpty(); - // password has to be at least 4 characters long var errors = req.validationErrors(); if (errors) { @@ -89,9 +87,9 @@ router.post('/signin', loggedOut, function(req, res, next) { failureRedirect: '/user/signin', failureFlash: true })(req, res); - } + }); module.exports = router; diff --git a/views/user_profile_alt.hbs b/views/user_profile_alt.hbs index 8b102b8..413fd0f 100644 --- a/views/user_profile_alt.hbs +++ b/views/user_profile_alt.hbs @@ -32,7 +32,7 @@
-

Walter White

+

{{ user.f_name }} {{ user.l_name }}

@@ -47,78 +47,69 @@ - - + + + {{# if user.university }} + + + + + {{/if}} + {{# if user.department }} - + + {{/if}} - + - + - - - - - - - - - + + {{# if user.phone_num}} + + + + + {{/if}}
Univeristy:U of TEmail:{{ user.email }}
University:{{ user.university }}
Department:CS{{ user.department }}
Answered:50{{ user.answered }}
Messages:25{{ user.messages }}
Comments:100
Email:info@support.com
Phone Number:111-111-1111(Mobile){{ user.comments }}
Phone Number:{{ user.phone_num }}
-

You are following:

-
- - - - - + {{# if user.followers }} +

You are being followed by:

+
+
- avatar - -

The Dude

-

3 comments

-
+ + {{# each user.followers}} + + + - - - - - - - - - - - -
+ avatar + +

The Dude

+

3 comments

+
- avatar - -

He-Man

-

20 comments

-
- avatar - -

Lady Lips

-

56 comments

-
-
+ + {{/each}} + + +
+ {{ else }} +

You do not have any followers.

+ {{/if}}

Friends

-- cgit v1.2.3