Skip to content

Commit

Permalink
Merge pull request #33 from bq/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
avalero authored Aug 17, 2018
2 parents e2483ff + bb3b7ba commit e1aa46f
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/api/user/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ router.get('/', auth.hasRole('admin'), controller.index);
router.post('/social', auth.getUser(), controller.socialLogin);
router.post('/forgot', controller.emailToken);
router.post('/all', auth.hasRole('admin'), controller.createAll);
router.post('/deleteMyAccount', auth.isAuthenticated(), controller.deleteMyAccount);
router.post('/', controller.create);

// PUT
Expand Down
35 changes: 35 additions & 0 deletions app/api/user/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,41 @@ exports.destroy = function(req, res) {

};

/**
* Deletes logged user account
*/
exports.deleteMyAccount = function(req, res) {
var userId = req.user._id;
var email = String(req.body.email);
var password = String(req.body.password);

async.waterfall(
[
function(callback) {
User.findById(userId, callback);
},

function(user, callback) {
if (user.email !== email) {
res.status(400).send('wrongEmail');
} else if (!user.authenticate(password)) {
res.status(400).send('wrongPassword');
} else {
user.anonymize('requestByUser', callback);
}
}
],
function(err) {
if (err) {
err.code = utils.getValidHttpErrorCode(err);
res.status(err.code).send(err);
} else {
res.sendStatus(200);
}
}
);
};

/**
* Give password to a social user
*/
Expand Down
2 changes: 1 addition & 1 deletion app/api/user/user.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ UserSchema.methods = {
this.email = '[email protected]' + Date.now();
this.username = 'anon' + Date.now();
this.password = Date.now() * Math.random();
this.bannedInForum = true;
this.bannedInForum = false;
this.needValidation = false;
this.tutor = {
dni: '',
Expand Down
27 changes: 26 additions & 1 deletion app/static/boards_3-8-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -2139,6 +2139,14 @@
"showInToolbox": true,
"order": 3,
"pinSize": {
"i2c-5": {
"h": 9,
"w": 9
},
"i2c-4": {
"h": 9,
"w": 9
},
"greymotor": {
"h": 41,
"w": 25
Expand All @@ -2157,6 +2165,22 @@
}
},
"pins": {
"i2c-5": [
{
"uid": "buidandcode-i2c5",
"name": "A5",
"y": 0.82,
"x": 0.568
},
],
"i2c-4": [
{
"uid": "buidandcode-i2c4",
"name": "A4",
"y": 0.82,
"x": 0.535
}
],
"greymotor": [
{
"y": 0.448,
Expand Down Expand Up @@ -2311,7 +2335,8 @@
"irs2",
"servo",
"hts221",
"lcd",
"lcdebotics",
"lcdgeneric",
"device",
"us",
"joystick",
Expand Down
35 changes: 35 additions & 0 deletions app/static/components_3-8-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@
]
}
}
}, {
"data": {
"uuid": "us3",
"manufacturer": "standard",
"category": "sensors",
"type": "US",
"width": 120,
"height": 79,
"dataReturnType": "float",
"pins": {
"digital": [
"s"
]
}
}
}, {
"data": {
"uuid": "button",
Expand Down Expand Up @@ -307,6 +322,26 @@
]
}
}
}, {
"data": {
"uuid": "lcdebotics",
"manufacturer": "standard",
"category": "lcds",
"width": 170,
"height": 93,
"pin": {
"sda": "a4",
"scl": "a5"
},
"pins": {
"i2c-4": [
"sda"
],
"i2c-5": [
"scl"
]
}
}
}, {
"data": {
"uuid": "bt",
Expand Down

0 comments on commit e1aa46f

Please sign in to comment.