Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
Removed demo button
Changed carousel indicators and arrows color to blue
Block user from changing their profile information if they are using a demo account
  • Loading branch information
githubalexliu committed May 21, 2018
1 parent e78b54d commit 8033b4a
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 20 deletions.
47 changes: 32 additions & 15 deletions app/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,36 +57,53 @@ module.exports = function(app, passport) {
});

app.post('/changename', function(req, res) {
if (req.user.username === 'demo') {
req.flash('messageFail', 'Sorry. You are using a demo account so you cannot \
change your name.');
res.redirect('back');
}
changeName(req.user.id, req.body.firstname, req.body.lastname);
req.flash('messageSuccess', 'Your name has been changed.');
res.redirect('back');
});

app.post('/changeemail', function(req, res) {
if (req.user.username === 'demo') {
req.flash('messageFail', 'Sorry. You are using a demo account so you cannot \
change your email.');
res.redirect('back');
}
changeEmail(req.user.id, req.body.email);
req.flash('messageSuccess', 'Your email has been changed.');
res.redirect('back');
});

app.post('/changepw', function(req, res) {
if (req.user.username === 'demo') {
req.flash('messageFail', 'Sorry. You are using a demo account so you cannot \
change your password.');
res.redirect('back');
}
// Is there a way to move this into profile.js?
// If I move the redirect out of connection.query, the messages are not flashed
// I can't move redirect into the module
connection.query("SELECT * FROM users WHERE id = ?", [req.user.id], function(err, rows) {
if (err) throw err;
else if (!bcrypt.compareSync(req.body.oldpw, rows[0].password)) {
req.flash('messageFail', 'Your old password is incorrect.');
} else if (req.body.newpw !== req.body.newpw2) {
req.flash('messageFail', 'Your new passwords do not match.');
} else {
connection.query("UPDATE users SET password = ? WHERE id = ?", [bcrypt.hashSync(req.body.newpw, null, null), req.user.id], function(err, rows) {
if (err) throw err;
});
req.flash('messageSuccess', 'Your password has been changed. Please \
logout for your new password to take effect.');
}
res.redirect('back');
});
else {
connection.query("SELECT * FROM users WHERE id = ?", [req.user.id], function(err, rows) {
if (err) throw err;
else if (!bcrypt.compareSync(req.body.oldpw, rows[0].password)) {
req.flash('messageFail', 'Your old password is incorrect.');
} else if (req.body.newpw !== req.body.newpw2) {
req.flash('messageFail', 'Your new passwords do not match.');
} else {
connection.query("UPDATE users SET password = ? WHERE id = ?", [bcrypt.hashSync(req.body.newpw, null, null), req.user.id], function(err, rows) {
if (err) throw err;
});
req.flash('messageSuccess', 'Your password has been changed. Please \
logout for your new password to take effect.');
}
res.redirect('back');
});
}
});

app.get('/word-list', isLoggedIn, function(req, res) {
Expand Down
16 changes: 16 additions & 0 deletions public/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,19 @@
.modal-lg {
max-width: 80% !important;
}

.carousel-indicators li {
background-color: #0000FF;
}

.carousel-indicators .active {
background-color: #5B9BD5;
}

.carousel-control-prev-icon {
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%235B9BD5' viewBox='0 0 8 8'%3E%3Cpath d='M5.25 0l-4 4 4 4 1.5-1.5-2.5-2.5 2.5-2.5-1.5-1.5z'/%3E%3C/svg%3E") !important;
}

.carousel-control-next-icon {
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%235B9BD5' viewBox='0 0 8 8'%3E%3Cpath d='M2.75 0l-1.5 1.5 2.5 2.5-2.5 2.5 1.5 1.5 4-4-4-4z'/%3E%3C/svg%3E") !important;
}
Binary file modified public/img/img2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/img/img3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions views/welcome.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<div class="carousel-inner">
<div class="carousel-item active">
<img src="public/img/img1.jpg" alt="First Slide">
<img src="public/img/img1.jpg" alt="First Slide"></a>
</div>
<div class="carousel-item">
<img src="public/img/img2.jpg" alt="Second Slide">
Expand Down Expand Up @@ -61,10 +61,10 @@
<div class="col-md-5">
<div class="row">
<div class="col-md-12">
<label for="register">New User?</label>
<button class="btn btn-default btn-block btn-lg" onclick="location.href='/signup'">Sign Up</button>
<label></label>
<button class="btn btn-default btn-block btn-lg">Demo</button>
<h3>New User?</h3>
<div class="mt-4">
<button class="btn btn-primary btn-block" onclick="location.href='/signup'">Sign Up</button>
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit 8033b4a

Please sign in to comment.