diff options
| author | HumairAK <humair88@hotmail.com> | 2016-07-24 06:12:21 +0000 |
|---|---|---|
| committer | HumairAK <humair88@hotmail.com> | 2016-07-24 06:12:21 +0000 |
| commit | 3e777af0387821e7a7fe03792cf79915d1b20bc7 (patch) | |
| tree | c8c8df68f6d11c16b2fb439cb60ec3b9639b56eb | |
| parent | c7c6495993e29d1d51defcad6925274e9efa0bc8 (diff) | |
fixed inbox mail pull
| -rw-r--r-- | config/passport.js | 18 | ||||
| -rw-r--r-- | routes/index.js | 1 | ||||
| -rw-r--r-- | routes/user.js | 12 | ||||
| -rw-r--r-- | views/user_profile_alt.hbs | 466 |
4 files changed, 257 insertions, 240 deletions
diff --git a/config/passport.js b/config/passport.js index 6cb6292..38e9397 100644 --- a/config/passport.js +++ b/config/passport.js @@ -15,17 +15,31 @@ var comparePassword = function (password1, password2) { passport.serializeUser(function (user, done) { - + //console.log("In serialize User"); + //console.log(user); done(null, user); }); passport.deserializeUser(function(user, done) { - + //console.log("In de-serialize User: " + user.email); done(null, user); }); +/* +passport.serializeUser(function (user, done) { + console.log("In serialize User"); + console.log(user); + done(null, user._id); +}); +passport.deserializeUser(function(id, done) { + console.log("In de-serialize User"); + dbFile.findUserByID(id, function(err, user){ + done(err, user); + }); +});*/ + // fields - [email, user_name, f_name, l_name, uni, department, password, phone_num] diff --git a/routes/index.js b/routes/index.js index 961a60d..ae7b194 100644 --- a/routes/index.js +++ b/routes/index.js @@ -86,7 +86,6 @@ router.get('/search', function(req, res, next) { res.redirect('/exams/' + courseName); }); - /* This is a redirect from the exams page, route is generated in exams.hbs * * EXAMPLE DATA GIVEN BELOW: diff --git a/routes/user.js b/routes/user.js index b2864b8..f88be68 100644 --- a/routes/user.js +++ b/routes/user.js @@ -76,7 +76,7 @@ router.get('/user_profile', loggedIn, isUser, function(req, res, next) { inbox.push(mail_data); inbox.push(mail_data); - res.render('user_profile_alt', {comments : comments, inbox: inbox}); + res.render('user_profile_alt', {comments : comments, inbox: inbox, csrfToken: req.csrfToken()}); }); /* Adds a solution into the database, redirect to exam/question/solution page */ @@ -207,7 +207,7 @@ router.post('/signin', loggedOut, function(req, res, next) { }); -router.get('/user_profile/send_message/:id', loggedIn, function(req, res, next) { +router.post('/user_profile/send_message', loggedIn, function(req, res, next) { var date = new Date(); var current_date = date.toString().slice(0, 24); var mail_data = { @@ -215,8 +215,10 @@ router.get('/user_profile/send_message/:id', loggedIn, function(req, res, next) receiver: req.body.receiver_username, message: req.body.message, date: current_date - } + }; + console.log(mail_data); + /* dbFile.sendMail(mail_data, function(success, error, message) { if ((!success && !error) || (error)) { res.redirect('/user/user_profile', {error: message}); @@ -225,9 +227,9 @@ router.get('/user_profile/send_message/:id', loggedIn, function(req, res, next) res.redirect('/user/user_profile', {success: message}); $('#profile-send-message').show(); } - }); + });*/ - //res.redirect('/user/user_profile'); + res.redirect('/user/user_profile'); }); module.exports = router; diff --git a/views/user_profile_alt.hbs b/views/user_profile_alt.hbs index 652cfee..ab6a9ce 100644 --- a/views/user_profile_alt.hbs +++ b/views/user_profile_alt.hbs @@ -1,257 +1,259 @@ <main id="solutions-main"> - <div class="container user-info-content"> - <div class="row"> +<div class="container user-info-content"> +<div class="row"> - <!-- User Profile details --> - <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 col-xs-offset-0 - col-sm-offset-0 col-md-offset-3 col-lg-offset-3 toppad prf-details"> +<!-- User Profile details --> +<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 col-xs-offset-0 +col-sm-offset-0 col-md-offset-3 col-lg-offset-3 toppad prf-details"> - <!-- User Profile Menu --> - <nav class="navbar navbar-custom"> - <div class="container-fluid"> - <div class="navbar-header"> - <button type="button" class="navbar-toggle" - data-toggle="collapse" data-target="#profile-nav"> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - </button> - </div> - <div class="collapse navbar-collapse" id="profile-nav"> - <ul class="nav navbar-nav " > - <li><a href="#" class="prf-page">General</a></li> - <li><a href="#" class="prf-page">Following</a></li> - <li><a href="#" class="prf-page">Friends</a></li> - <li><a href="#" class="prf-page">Send Message</a></li> - <li><a href="#" class="prf-page">Inbox</a></li> - <li><a href="#" class="prf-page">Comments</a></li> - </ul> - </div> - </div> - </nav> - - <div class="rounded"> - <div class="panel panel-info rounded"> - <div class="panel-heading"> - <h3 class="panel-title">{{ user.f_name }} {{ user.l_name }}</h3> - </div> - <div class="panel-body"> - <!--- User-Profile Pages --> - <div class="row" id="profile-general"> - <!-- User Image --> - <div class="col-md-3 col-lg-3 " align="center"> - <img alt="User Pic" src="../assets/images/avatar.png" - class="img-circle img-responsive"> - </div> - <!-- User Details --> - <div class=" col-md-9 col-lg-9 "> - <table class="table table-user-information"> - <tbody> - <tr> - <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>{{ user.department }}</td> - </tr> - {{/if}} - <tr> - <td>Answered:</td> - <td>{{ user.answered }}</td> - </tr> - <tr> - <tr> - <td>Messages:</td> - <td>{{ user.messages }}</td> - </tr> - <tr> - <td>Comments:</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"> - {{# 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> + <!-- User Profile Menu --> + <nav class="navbar navbar-custom"> + <div class="container-fluid"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle" + data-toggle="collapse" data-target="#profile-nav"> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + </div> + <div class="collapse navbar-collapse" id="profile-nav"> + <ul class="nav navbar-nav " > + <li><a href="#" class="prf-page">General</a></li> + <li><a href="#" class="prf-page">Following</a></li> + <li><a href="#" class="prf-page">Friends</a></li> + <li><a href="#" class="prf-page">Send Message</a></li> + <li><a href="#" class="prf-page">Inbox</a></li> + <li><a href="#" class="prf-page">Comments</a></li> + </ul> + </div> + </div> + </nav> - </tr> - {{/each}} - </tbody> - </table> - </div> - {{ else }} - <h3>You are not following any exams.</h3> - {{/if}} - </div> - <div class="row" id="profile-friends"> - <h3>Friends</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/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/user5.jpeg" alt="avatar"> - </th> - <th> - <h4>Jay Leno</h4> - <p>5 comments</p> - </th> - </tr> + <div class="rounded"> + <div class="panel panel-info rounded"> + <div class="panel-heading"> + <h3 class="panel-title">{{ user.f_name }} {{ user.l_name }}</h3> + </div> + <div class="panel-body"> + <!--- User-Profile Pages --> + <div class="row" id="profile-general"> + <!-- User Image --> + <div class="col-md-3 col-lg-3 " align="center"> + <img alt="User Pic" src="../assets/images/avatar.png" + class="img-circle img-responsive"> + </div> + <!-- User Details --> + <div class=" col-md-9 col-lg-9 "> + <table class="table table-user-information"> + <tbody> + <tr> + <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>{{ user.department }}</td> + </tr> + {{/if}} + <tr> + <td>Answered:</td> + <td>{{ user.answered }}</td> + </tr> + <tr> + <tr> + <td>Messages:</td> + <td>{{ user.messages }}</td> + </tr> + <tr> + <td>Comments:</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"> + {{# 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/user6.jpeg" alt="avatar"> + src="../assets/images/misc/user1.jpeg" alt="avatar"> </th> <th> - <h4>Lisa Simpson</h4> - <p>658 comments</p> + <h4>The Dude</h4> + <p>3 comments</p> </th> + </tr> - </tbody> - </table> - </div> - </div> - {{# if success }} - <section class="alert alert-success"> - <!-- Change those to banners later --> - <h2>{{ success }}</h2> - </section> - {{ else }} - {{# if error }} - <section class="alert alert-danger"> - <h2>{{ error }}</h2> - </section> - {{/if}} - {{/if}} - <div class="row" id="profile-send-message"> - <h3>Send Message</h3> - <div class="col-xs-offset-1 col-sm-offset-3 col-xs-10 col-sm-6"> - <form action="/user_profile/send_message" method="GET"> - <div class="form-group"> - <label for="receiver">Send To:</label> - <input type="text" class="form-control" placeholder="Username" name="receiver_username"> - </div> - <div class="form-group"> - <label for="sending-message">Message:</label> - <textarea class="form-control" rows="3" name="message"></textarea> - </div> - <button class="btn btn-primary">Send Message</button> - </form> - </div> + {{/each}} + </tbody> + </table> + </div> + {{ else }} + <h3>You are not following any exams.</h3> + {{/if}} + </div> + <div class="row" id="profile-friends"> + <h3>Friends</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/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/user5.jpeg" alt="avatar"> + </th> + <th> + <h4>Jay Leno</h4> + <p>5 comments</p> + </th> + </tr> + <tr> + <th> + <img class="img-circle img-responsive" + src="../assets/images/misc/user6.jpeg" alt="avatar"> + </th> + <th> + <h4>Lisa Simpson</h4> + <p>658 comments</p> + </th> + </tr> + </tbody> + </table> + </div> + </div> + {{# if success }} + <section class="alert alert-success"> + <!-- Change those to banners later --> + <h2>{{ success }}</h2> + </section> + {{ else }} + {{# if error }} + <section class="alert alert-danger"> + <h2>{{ error }}</h2> + </section> + {{/if}} + {{/if}} + <div class="row" id="profile-send-message"> + <h3>Send Message</h3> + <div class="col-xs-offset-1 col-sm-offset-3 col-xs-10 col-sm-6"> + <form action="/user/user_profile/send_message" method="post"> + <div class="form-group"> + <label for="receiver">Send To:</label> + <input type="text" class="form-control" placeholder="Username" name="receiver_username"> </div> - <div class="row" id="profile-inbox"> - {{# if inbox }} - <h3>Inbox</h3> - <div class="col-sm-10 col-sm-offset-1 prf-tables"> - <table class="table"> - <thead> - <tr> - <th>Date</th> - <th>Subject</th> - <th>Sender</th> - </tr> - </thead> - <tbody> - {{# each inbox }} - <tr> - <td>{{ this.date }}</td> - <td>{{ this.message }}</td> - <td>{{ this.sender }}</td> - </tr> - {{/each}} - </tbody> - </table> - </div> - {{ else }} - <h3>No Messages.</h3> - {{/if}} + <div class="form-group"> + <label for="sending-message">Message:</label> + <textarea class="form-control" rows="3" name="message"></textarea> </div> - <div class="row" id="profile-comments"> + <button class="btn btn-primary">Send Message</button> + <input type="hidden" name="_csrf" value="{{ csrfToken }}"> + </form> + </div> + </div> + <div class="row" id="profile-inbox"> + {{# if inbox }} + <h3>Inbox</h3> + <div class="col-sm-10 col-sm-offset-1 prf-tables"> + <table class="table"> + <thead> + <tr> + <th>Date</th> + <th>Subject</th> + <th>Sender</th> + </tr> + </thead> + <tbody> + {{# each inbox }} + <tr> + <td>{{ this.date }}</td> + <td>{{ this.message }}</td> + <td>{{ this.sender }}</td> + </tr> + {{/each}} + </tbody> + </table> + </div> + {{ else }} + <h3>No Messages.</h3> + {{/if}} + </div> + <div class="row" id="profile-comments"> - {{# if comments }} - <h3>Comment History</h3> - <div class="col-sm-10 col-sm-offset-1 prf-tables"> - <table class="table"> - <thead> - <tr> - <th>Date</th> - <th>Comment</th> - <th>Exam</th> - </tr> - </thead> - <tbody> - {{# each comments }} - <tr> - <td>{{ this.date }}</td> - <td>{{ this.comment }}</td> - <td>{{ this.exam_info.course_code }} > {{ this.exam_info.term }} - {{ this.exam_info.year }}</td> - </tr> - {{/each}} + {{# if comments }} + <h3>Comment History</h3> + <div class="col-sm-10 col-sm-offset-1 prf-tables"> + <table class="table"> + <thead> + <tr> + <th>Date</th> + <th>Comment</th> + <th>Exam</th> + </tr> + </thead> + <tbody> + {{# each comments }} + <tr> + <td>{{ this.date }}</td> + <td>{{ this.comment }}</td> + <td>{{ this.exam_info.course_code }} > {{ this.exam_info.term }} + {{ this.exam_info.year }}</td> + </tr> + {{/each}} - </table> + </table> - </div> - {{else}} - <h3>No Comments.</h3> - {{/if}} + </div> + {{else}} + <h3>No Comments.</h3> + {{/if}} - </div> + </div> - <!-- Date, Edit, Logout (new row) --> - <div class="col-md-12 prf-sign-off"> - <p class=" text-info"> July 4 2016 </p> - <a href="#">Edit Profile</a> - <a href="#">Logout</a> - <br> + <!-- Date, Edit, Logout (new row) --> + <div class="col-md-12 prf-sign-off"> + <p class=" text-info"> July 4 2016 </p> + <a href="#">Edit Profile</a> + <a href="#">Logout</a> + <br> - </div> - </div> - </div> </div> - </div> </div> </div> + +</div> + +</div> +</div> </main>
\ No newline at end of file |
