diff options
| -rw-r--r-- | app.js | 2 | ||||
| -rw-r--r-- | routes/user.js | 8 | ||||
| -rw-r--r-- | views/user_profile_alt.hbs | 97 |
3 files changed, 49 insertions, 58 deletions
@@ -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 @@ <div class="rounded"> <div class="panel panel-info rounded"> <div class="panel-heading"> - <h3 class="panel-title">Walter White</h3> + <h3 class="panel-title">{{ user.f_name }} {{ user.l_name }}</h3> </div> <div class="panel-body"> <!--- User-Profile Pages --> @@ -47,78 +47,69 @@ <table class="table table-user-information"> <tbody> <tr> - <td>Univeristy:</td> - <td>U of T</td> + <td>Email:</td> + <td><a href="{{ user.email }}">{{ user.email }}</a></td> </tr> + {{# if user.university }} + <tr> + <td>University:</td> + <td>{{ user.university }}</td> + </tr> + {{/if}} + {{# if user.department }} <tr> <td>Department:</td> - <td>CS</td> + <td>{{ user.department }}</td> </tr> + {{/if}} <tr> <td>Answered:</td> - <td>50</td> + <td>{{ user.answered }}</td> </tr> <tr> <tr> <td>Messages:</td> - <td>25</td> + <td>{{ user.messages }}</td> </tr> <tr> <td>Comments:</td> - <td>100</td> - </tr> - <tr> - <td>Email:</td> - <td><a href="mailto:info@support.com">info@support.com</a></td> - </tr> - <tr> - <td>Phone Number:</td> - <td>111-111-1111(Mobile)</td> + <td>{{ user.comments }}</td> </tr> + {{# if user.phone_num}} + <tr> + <td>Phone Number:</td> + <td>{{ user.phone_num }}</td> + </tr> + {{/if}} </tbody> </table> </div> </div> <div class="row" id="profile-follows"> - <h3>You are following:</h3> - <div class="col-xs-offset-1 col-sm-offset-3 col-xs-10 col-sm-6"> - <table class="table-condensed"> - <tbody> - <tr> - <th> - <img class="img-circle img-responsive" - src="../assets/images/misc/user1.jpeg" alt="avatar"> - </th> - <th> - <h4>The Dude</h4> - <p>3 comments</p> - </th> + {{# if user.followers }} + <h3>You are being followed by:</h3> + <div class="col-xs-offset-1 col-sm-offset-3 col-xs-10 col-sm-6"> + <table class="table-condensed"> + <tbody> + {{# each user.followers}} + <tr> + <th> + <img class="img-circle img-responsive" + src="../assets/images/misc/user1.jpeg" alt="avatar"> + </th> + <th> + <h4>The Dude</h4> + <p>3 comments</p> + </th> - </tr> - <tr> - <th> - <img class="img-circle img-responsive" - src="../assets/images/misc/user2.jpeg" alt="avatar"> - </th> - <th> - <h4>He-Man</h4> - <p>20 comments</p> - </th> - </tr> - <tr> - <th> - <img class="img-circle img-responsive" - src="../assets/images/misc/user3.jpeg" alt="avatar"> - </th> - <th> - <h4>Lady Lips</h4> - <p>56 comments</p> - </th> - </tr> - </tbody> - - </table> - </div> + </tr> + {{/each}} + </tbody> + </table> + </div> + {{ else }} + <h3>You do not have any followers.</h3> + {{/if}} </div> <div class="row" id="profile-friends"> <h3>Friends</h3> |
