Skip to content

Commit bdf259f

Browse files
committed
Changed encryptedPW to password
1 parent 79b9ca0 commit bdf259f

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ API endpoints at ```localhost:8000/api/``` :
2222

2323
| Method | Path | Parameters | Protected | |
2424
| :---: | :---: | :---: | :---: | :--- |
25-
| POST | /user | username : encryptedPW | none | Create a User and returns token|
25+
| POST | /user | username : password | none | Create a User and returns token|
2626
| GET | /user | - - - | none | Returns List of User Objects |
2727
| GET | /user/:id | - - - | none | Returns the user with the given ID |
2828
| PUT | /user/:id | - - - | isAuthorized, isCurrentUser | Updates user with the a given ID |
2929
| DEL | /user/:id | - - - | isAuthorized, isCurrentUser | Deletes a user with the given ID |
30-
| POST | /login | username : encryptedPW | none | Log In Route : Returns logged in user and token |
30+
| POST | /login | username : password | none | Log In Route : Returns logged in user and token |
3131

3232

3333

server/controllers/userController.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var tokenAuth = require('../services/tokenAuth');
88
exports.register = function(req , res){
99

1010
if(!req.body.username){return res.json({Error : "Username is Required"});}
11-
if(!req.body.encryptedPW){return res.json({Error : "Password is Required"});}
11+
if(!req.body.password){return res.json({Error : "Password is Required"});}
1212

1313
User.filter({username:req.body.username}).run().then(function(userArray){
1414
if(userArray[0]){return res.json({Error : "Username is in use"});}
@@ -55,7 +55,7 @@ exports.editUser = function(req , res){
5555
var id = req.params.id;
5656
User.get(id).run().then(function(user){
5757
if (req.body.username) {user.username = req.body.username;}
58-
if (req.body.encyptedPW) {user.encryptedPW = req.body.encryptedPW;}
58+
if (req.body.encyptedPW) {user.password = req.body.password;}
5959
user.save().then(function(result) {
6060
res.json({ message: 'User Updated !!'});
6161
}).error(function(res){

server/models/user.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var bcrypt = require('bcrypt');
66
var User = thinky.createModel("user", {
77

88
username : type.string(),
9-
encryptedPW : type.string()
9+
password : type.string()
1010

1111
});
1212

@@ -18,10 +18,10 @@ User.pre('save', function(next) {
1818
bcrypt.genSalt(10, function (err, salt) {
1919

2020
if(err) return next(err);
21-
bcrypt.hash(self.encryptedPW, salt, function (err, hash) {
21+
bcrypt.hash(self.password, salt, function (err, hash) {
2222

2323
if(err) return next(err);
24-
self.encryptedPW = hash;
24+
self.password = hash;
2525
next();
2626

2727
});
@@ -31,7 +31,7 @@ User.pre('save', function(next) {
3131

3232
User.comparePassword = function(password, user, callback) {
3333

34-
bcrypt.compare(password, user.encryptedPW, function(err, match) {
34+
bcrypt.compare(password, user.password, function(err, match) {
3535

3636
if (err) callback(err);
3737

0 commit comments

Comments
 (0)