Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Commit

Permalink
requested fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
butlerx committed Dec 29, 2017
1 parent ffce999 commit e220244
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
33 changes: 14 additions & 19 deletions lib/users/unlock-account-email.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const moment = require('moment');
const options = require('../../config/config');

const protocol = process.env.PROTOCOL || 'http';
const zenHostname = process.env.HOSTNAME || '127.0.0.1:8000';
Expand All @@ -10,24 +9,20 @@ function unlockAccountEmail(args, done) {

seneca.act({ role: 'cd-users', cmd: 'get_users_by_email', email }, (err, users) => {
if (err) return done(err);
if (options['email-notifications'].sendemail) {
seneca.act({ role: 'email-notifications', cmd: 'send' }, {
code: 'user-lockout-',
locality: args.locality || 'en_US',
to: email,
subject: 'CoderDojo Zen Account Lockout',
content: {
name: users[0].name,
resetlink: `${protocol}://${zenHostname}/reset_password`,
year: moment(new Date()).format('YYYY'),
},
}, (err, response) => {
if (err) return done(err);
return done(null, { ok: true });
});
} else {
return done(null, { ok: false });
}
seneca.act({ role: 'email-notifications', cmd: 'send' }, {
code: 'user-lockout-',
locality: args.locality || 'en_US',
to: email,
subject: 'CoderDojo Zen Account Lockout',
content: {
name: users[0].name,
resetlink: `${protocol}://${zenHostname}/reset_password`,
year: moment(new Date()).format('YYYY'),
},
}, (err, response) => {
if (err) return done(err);
return done(null, { ok: true });
});
});
}

Expand Down
2 changes: 1 addition & 1 deletion service.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ require('./migrate-psql-db.js')(function (err) {
logger: log.logger
});
seneca.use(require('./oauth2.js'), {clients: config.oauth2.clients});
seneca.use('user', { failedCount: 3 });
seneca.use('user', { failedLoginCount: 3 });
seneca.use('auth');
seneca.use(require('./users.js'),
{ 'email-notifications': config['email-notifications'],
Expand Down

0 comments on commit e220244

Please sign in to comment.