Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Release 0.1.3

  • Loading branch information...
commit d318e43d616e8cfb53a624299011054ae998f222 1 parent efd6654
@niftylettuce authored
View
2  Readme.md
@@ -1,7 +1,7 @@
# Expressling
-Latest release: `v0.1.2`, featuring `mongoose-troop`.
+Latest release: `v0.1.3`, with bug fixes for `mongoose-troop` integration in previous version.
Open source [node.js](http://nodejs.org) + [express](http://expressjs.com/) application framework.
View
5 package.json
@@ -1,11 +1,8 @@
{
"name": "expressling"
, "description": "Expressling "
- , "version": "0.1.2"
+ , "version": "0.1.3"
, "author": "Nick Baugh <niftylettuce@gmail.com>"
- , "contributors": [
- { "name": "Butu", "email": "butu25@gmail.com" }
- ]
, "keywords": [
"expressling"
, "express"
View
23 routes/my-account.js
@@ -65,18 +65,20 @@ module.exports = function(app, db) {
if(!req.form.isValid) {
redirectToMyAccount(req, res);
} else {
+ var changed = false;
+ var newPassword = '';
// Check if user wants to change password
if(req.form.password !== "" && req.form.password_confirmation !== "") {
if(req.form.password !== req.form.password_confirmation) {
req.flash('error', 'Password confirmation does not match entered password, try again');
redirectToMyAccount(req, res);
} else {
- delete req.form.password_confirmation;
+ changed = true;
+ newPassword = req.form.password;
}
- } else {
- delete req.form.password;
- delete req.form.password_confirmation;
}
+ delete req.form.password;
+ delete req.form.password_confirmation;
// Save the user's changes and redirect to My Account
Users.findById(req.session.auth._id, function(err, user) {
if(err) {
@@ -85,7 +87,6 @@ module.exports = function(app, db) {
}
if(user) {
// Iterate through object properties
- var changed = false;
for(var attr in req.form) {
if(user[attr] !== req.form[attr]) {
if(attr !== "name") {
@@ -115,9 +116,17 @@ module.exports = function(app, db) {
redirectToMyAccount(req, res);
}
}
+ req.flash('success', 'Changes to your account information have been saved');
if(user) {
- req.flash('success', 'Changes to your account information have been saved');
- res.redirect('/my-account');
+ if (newPassword !== '') {
+ user.setPassword(newPassword, function(err) {
+ if (err) throw err;
+ req.flash('success', 'New password set successfully');
+ return res.redirect('/my-account');
+ });
+ } else {
+ return res.redirect('/my-account');
+ }
}
});
} else {
View
5 schemas/users.js
@@ -39,8 +39,9 @@ module.exports = function(db) {
});
Users.plugin(troop.timestamp);
- troop.basicAuth(Users, { loginPath: 'email' });
-
+ Users.plugin(troop.basicAuth, {
+ loginPath: 'email'
+ });
Users.static('access', exports.access(db));
Users.static('groupCount', exports.groupCount);
Please sign in to comment.
Something went wrong with that request. Please try again.