From ffce9999a80615e1c3577196d4ff8707f3446d24 Mon Sep 17 00:00:00 2001 From: butlerx Date: Thu, 28 Dec 2017 14:03:49 +0000 Subject: [PATCH] fix errors --- lib/users/unlock-account-email.js | 39 ++++++++++--------- package.json | 2 +- ...user-lock.sql => 025.do.add-user-lock.sql} | 2 +- 3 files changed, 22 insertions(+), 21 deletions(-) rename scripts/database/pg/migrations/{024.do.add-user-lock.sql => 025.do.add-user-lock.sql} (57%) diff --git a/lib/users/unlock-account-email.js b/lib/users/unlock-account-email.js index b54659f6..9a9df5fd 100644 --- a/lib/users/unlock-account-email.js +++ b/lib/users/unlock-account-email.js @@ -1,31 +1,32 @@ -'use strict'; -var async = require('async'); -var _ = require('lodash'); -var protocol = process.env.PROTOCOL || 'http'; -var zenHostname = process.env.HOSTNAME || '127.0.0.1:8000'; +const moment = require('moment'); +const options = require('../../config/config'); -function unlockAccountEmail (args, cb) { - var seneca = this; - var email = args.email; - var locality = args.locality || 'en_US'; - var emailCode = 'user-lockout-'; - var emailSubject = 'CoderDojo Zen Account Lockout'; +const protocol = process.env.PROTOCOL || 'http'; +const zenHostname = process.env.HOSTNAME || '127.0.0.1:8000'; - seneca.act({role: 'cd-users', cmd: 'get_users_by_email', email: email}, function (err, users) { +function unlockAccountEmail(args, done) { + const seneca = this; + const email = args.email; + + 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: emailCode, - locality: locality, + seneca.act({ role: 'email-notifications', cmd: 'send' }, { + code: 'user-lockout-', + locality: args.locality || 'en_US', to: email, - subject: emailSubject, - content: {name: users[0].name, resetlink: protocol + '://' + zenHostname + '/reset_password', year: moment(new Date()).format('YYYY')} - }, function (err, response) { + 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}); + return done(null, { ok: false }); } }); } diff --git a/package.json b/package.json index 71a69683..f4ae546a 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "seneca-mail": "^0.2.2", "seneca-postgresql-store": "2.3", "seneca-store-query": "0.0.5", - "seneca-user": "2.0.0", + "seneca-user": "2.1.1", "shortid": "2.2.2", "util": "^0.10.3", "xoauth2": "1.1.0" diff --git a/scripts/database/pg/migrations/024.do.add-user-lock.sql b/scripts/database/pg/migrations/025.do.add-user-lock.sql similarity index 57% rename from scripts/database/pg/migrations/024.do.add-user-lock.sql rename to scripts/database/pg/migrations/025.do.add-user-lock.sql index 61013377..8d1d02e0 100644 --- a/scripts/database/pg/migrations/024.do.add-user-lock.sql +++ b/scripts/database/pg/migrations/025.do.add-user-lock.sql @@ -3,7 +3,7 @@ DO $$ BEGIN ALTER TABLE sys_user ADD COLUMN failed_login_count integer; EXCEPTION - WHEN duplicate_column THEN RAISE NOTICE 'column token already exists in sys_user.'; + WHEN duplicate_column THEN RAISE NOTICE 'column failed_login_count already exists in sys_user.'; END; END; $$