Skip to content

Commit

Permalink
Resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ravisuhag committed Sep 26, 2016
2 parents cb4b654 + 5e63161 commit 716ffea
Show file tree
Hide file tree
Showing 179 changed files with 6,471 additions and 13,832 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets" : ["es2015", "react"]
}
7 changes: 1 addition & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
root = true

# Unix-style newlines with a newline ending every file

[**]
end_of_line = lf
insert_final_newline = true


# Standard at: https://github.com/felixge/node-style-guide

[**.js, **.json]
trim_trailing_whitespace = true
indent_style = tab
indent_size = 4
quote_type = single
curly_bracket_next_line = false
spaces_around_operators = true
Expand All @@ -23,9 +21,6 @@ space_after_anonymous_functions = false
spaces_in_brackets = false
tab_size= 4


# No standard. Please document a standard if different from .js

[**.md]
indent_style = tab

30 changes: 30 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
env:
browser: true
commonjs: true
es6: true
node: true
extends: 'eslint:recommended'
globals:
ga: true
parserOptions:
ecmaFeatures:
experimentalObjectRestSpread: true
jsx: true
sourceType: module
plugins:
- react
rules:
linebreak-style:
- error
- unix
quotes:
- error
- single
semi:
- error
- always
curly: error
eqeqeq: error
no-empty: warn
no-console: off
no-unused-vars: off
5 changes: 0 additions & 5 deletions .jsbeautifyrc

This file was deleted.

18 changes: 0 additions & 18 deletions .jshintrc

This file was deleted.

75 changes: 0 additions & 75 deletions app/controllers/alerts/notifications.js

This file was deleted.

64 changes: 64 additions & 0 deletions app/controllers/api/account.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
'use strict';

const Joi = require('joi');
const Boom = require('boom');
const Crypto = require('crypto');

exports.postChangePassword = {
description: 'Password change api',
validate: {
payload: {
oldPassword: Joi.string().min(6).max(20).required(),
newPassword: Joi.string().min(6).max(20).required(),
verify: Joi.string().required(),
},
failAction: function(request, reply, source, error) {
// Boom bad request
return reply(Boom.badRequest(error));
}
},
auth: {
mode: 'try',
strategy: 'standard'
},
plugins: {
'hapi-auth-cookie': {
redirectTo: false
}
},
handler: function(request, reply) {

if (!request.auth.isAuthenticated) {
return Boom.forbidden('You are not logged in');
}

if (request.payload.newPassword !== request.payload.verify) {
return reply(Boom.badRequest('New password does not match'));
}
var User = request.server.plugins.sequelize.db.User;

User.findOne({
where: {
username: request.auth.credentials.username,
password: Crypto.createHash('md5').update(request.payload.oldPassword).digest('hex')
}
}).then(function(user) {
if (user) {
user.update({
password: Crypto.createHash('md5').update(request.payload.newPassword).digest('hex')
}).then(function() {
request.cookieAuth.clear();

var msg = {
'statusCode': 200,
'message': 'Password changed successfully. Please login with new password'
};
return reply(msg);
});
} else {
// User not fond in database
return reply(Boom.badRequest('Old password is incorrect'));
}
});
}
};
Loading

0 comments on commit 716ffea

Please sign in to comment.