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

Commit

Permalink
Add support for account, \n add db migration for userlockout \n add e…
Browse files Browse the repository at this point in the history
…mail asking user to reset when account lockout
  • Loading branch information
butlerx committed Jul 14, 2016
1 parent 95e0741 commit 2718b26
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 78 deletions.
15 changes: 15 additions & 0 deletions email-templates/user-lockout-en_US/user-lockout.html.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<% include ../common-en_US/header.ejs %>

<h1>Hi <%=name%>,</h1>

<p>We have noticed multiple failed attempts to login to your zen account so for security reasons have locked your account. </p>

<p>To unlock your account you will need to change your password.</p>
<p>Please follow the link below to reset your password.</br>
<a href="<%=resetlink%>"><%=resetlink%></a></p>


<p>Best wishes,</br>
The CoderDojo Foundation Team</p>

<% include ../common-en_US/footer.ejs %>
10 changes: 10 additions & 0 deletions email-templates/user-lockout-en_US/user-lockout.text.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Hi <%=name%>;

We have noticed multiple failed attempts to login to your zen account so for security reasons have locked your account.

To unlock your account you will need to change your password.
Please follow the link below to reset your password.
<%=resetlink%>

Best wishes,
The CoderDojo Foundation Team
33 changes: 33 additions & 0 deletions lib/users/unlock-account-email.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'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';

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';

seneca.act({role: 'cd-users', cmd: 'get_users_by_email', email: email}, function (err, users) {
if (err) return done(err);
if (options['email-notifications'].sendemail) {
seneca.act({role: 'email-notifications', cmd: 'send'}, {
code: emailCode,
locality: locality,
to: email,
subject: emailSubject,
content: {name: users[0].name, resetlink: protocol + '://' + zenHostname + '/reset_password', year: moment(new Date()).format('YYYY')}
}, function (err, response) {
if (err) return done(err);
return done(null, { ok: true });
});
} else {
return done(null, {ok: false});
}
});
}

module.exports = unlockAccountEmail;
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
"po2json": "0.4.2",
"postgrator": "2.2.0",
"request": "2.58.0",
"seneca": "0.7.2",
"seneca-auth": "0.2.10",
"seneca": "1.4.0",
"seneca-auth": "1.0.0",
"seneca-mail": "0.2.1",
"seneca-postgresql-store": "1.1.3",
"seneca-user": "0.2.10",
"seneca-user": "1.0.0",
"cp-permissions-plugin": "git://github.com/CoderDojo/cp-permissions-plugin#0.0.1",
"shortid": "2.2.2",
"xoauth2": "1.1.0"
Expand Down
9 changes: 9 additions & 0 deletions scripts/database/pg/migrations/019.do.add-user-lock.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DO $$
BEGIN
BEGIN
ALTER TABLE sys_user ADD COLUMN lock_try integer;
EXCEPTION
WHEN duplicate_column THEN RAISE NOTICE 'column token already exists in sys_user.';
END;
END;
$$
5 changes: 3 additions & 2 deletions users.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ module.exports = function (options) {
seneca.add({role: plugin, cmd: 'kpi_number_of_youths_registered'}, cmd_kpi_number_of_youths_registered);
seneca.add({role: plugin, cmd: 'kpi_number_of_champions_and_mentors_registered'}, cmd_kpi_number_of_champions_and_mentors_registered);
seneca.add({role: plugin, cmd: 'kpi_number_of_youth_females_registered'}, cmd_kpi_number_of_youth_females_registered);
seneca.add({role: 'cd-users', cmd: 'is_self'}, require('./lib/users/is-self'));
seneca.add({role: 'cd-users', cmd: 'is_parent_of'}, require('./lib/users/is-parent-of'));
seneca.add({role: plugin, cmd: 'is_self'}, require('./lib/users/is-self'));
seneca.add({role: plugin, cmd: 'is_parent_of'}, require('./lib/users/is-parent-of'));
seneca.add({role: plugin, cmd: 'unlock_account_email'}, require('./lib/users/unlock-account-email'));

function cmd_load_prev_founder (args, done) {
var seneca = this;
Expand Down
77 changes: 4 additions & 73 deletions web/locale/en_US/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,6 @@ msgstr "All Dojos are independent, autonomous, community groups set up to inspir
msgid "We commit to inspiring and supporting young people to learn how to create technology"
msgstr "We commit to inspiring and supporting young people to learn how to create technology"

msgid "We commit to inspiring and supporting young people to learn how to create technology"
msgstr "We commit to inspiring and supporting young people to learn how to create technology"

msgid "We commit to the highest possible standards of child protection in our jurisdiction"
msgstr "We commit to the highest possible standards of child protection in our jurisdiction"

Expand Down Expand Up @@ -597,9 +594,6 @@ msgstr "Next"
msgid "Dojo Menu"
msgstr "Dojo Menu"

msgid "Events"
msgstr "Events"

msgid "Forum"
msgstr "Forum"

Expand Down Expand Up @@ -669,9 +663,6 @@ msgstr "Send Request"
msgid "Contact"
msgstr "Contact"

msgid "Email"
msgstr "Email"

msgid "Dojo Email"
msgstr "Dojo Email"

Expand Down Expand Up @@ -882,9 +873,6 @@ msgstr "unverified"
msgid "Stage"
msgstr "Stage"

msgid "Dojo Email"
msgstr "Dojo Email"

msgid "User Email"
msgstr "User Email"

Expand Down Expand Up @@ -957,15 +945,9 @@ msgstr "You must be over 18 years old..."
msgid "Please include country code..."
msgstr "Please include country code..."

msgid "Address"
msgstr "Address"

msgid "Enter your street level address..."
msgstr "Enter your street level address..."

msgid "Address is empty"
msgstr "Address is empty"

msgid "Technical Experience"
msgstr "Technical Experience"

Expand Down Expand Up @@ -1242,9 +1224,6 @@ msgstr "Newspaper/Magazine"
msgid "Radio"
msgstr "Radio"

msgid "Family/Friends"
msgstr "Family/Friends"

msgid "Error loading profile"
msgstr "Error loading profile:"

Expand Down Expand Up @@ -1323,9 +1302,6 @@ msgstr "Type"
msgid "For"
msgstr "For"

msgid "Name"
msgstr "Name"

msgid "Capacity"
msgstr "Capacity"

Expand Down Expand Up @@ -1707,9 +1683,6 @@ msgstr "Add Youth over 13"
msgid "This profile is private"
msgstr "This profile is private"

msgid "We need mentors!"
msgstr "We need mentors!"

msgid "Find out more about becoming a CoderDojo mentor"
msgstr "Find out more about becoming a CoderDojo mentor"

Expand Down Expand Up @@ -1743,15 +1716,9 @@ msgstr "An error has occured verifying the charter agreement."
msgid "error.general"
msgstr "There was an error on this page. Our technical staff have been notified"

msgid "Gather your Team"
msgstr "Gather your Team"

msgid "Find a Venue"
msgstr "Find a Venue"

msgid "Plan your Dojo"
msgstr "Plan your Dojo"

msgid "Promote your Dojo"
msgstr "Promote your Dojo"

Expand Down Expand Up @@ -1866,15 +1833,9 @@ msgstr "Optionally describe how this was achieved."
msgid "Data Protection: Our Dojo only uses data provided for the intended purpose. abides by data protection regulations in our jurisdiction."
msgstr "Data Protection: Our Dojo only uses data provided for the intended purpose. abides by data protection regulations in our jurisdiction."

msgid "Optionally describe how this was achieved."
msgstr "Optionally describe how this was achieved."

msgid "Diversity among our attendees is respected"
msgstr "Diversity among our attendees is respected"

msgid "Optionally describe how this was achieved."
msgstr "Optionally describe how this was achieved."

msgid "We will work to help engage with and improve the greater CoderDojo movement by"
msgstr "We will work to help engage with and improve the greater CoderDojo movement by"

Expand All @@ -1887,9 +1848,6 @@ msgstr "Contributing to Kata, the community knowledge base at kata.coderdojo.com
msgid "Connecting with local and international Dojos to share insights and supports"
msgstr "Connecting with local and international Dojos to share insights and supports"

msgid "Optionally describe how this was achieved."
msgstr "Optionally describe how this was achieved."

msgid "Admin permissions cannot be removed from a Dojo owner."
msgstr "Admin permissions cannot be removed from a Dojo owner."

Expand Down Expand Up @@ -2089,15 +2047,6 @@ msgstr "Invitation was sent successfully."
msgid "An error has occurred while sending invitation"
msgstr "An error has occurred while sending invitation"

msgid "We will work to embody the CoderDojo ethos"
msgstr "We will work to embody the CoderDojo ethos"

msgid "All mentors and young people are aware of online safety best practices and we only allow age appropriate content at our Dojo"
msgstr "All mentors and young people are aware of online safety best practices and we only allow age appropriate content at our Dojo"

msgid "Optionally describe how this was achieved."
msgstr "Optionally describe how this was achieved."

msgid "Our Dojo abides by data protection regulations in our jurisdiction"
msgstr "Our Dojo abides by data protection regulations in our jurisdiction"

Expand All @@ -2107,15 +2056,6 @@ msgstr "Inclusion is a fundamental principle of CoderDojo, <a href=\"http://kata
msgid "Our Dojo will work to engage with and improve the greater CoderDojo movement by:"
msgstr "Our Dojo will work to engage with and improve the greater CoderDojo movement by:"

msgid "Communicating with the CoderDojo Foundation"
msgstr "Communicating with the CoderDojo Foundation"

msgid "Contributing to Kata, the community knowledge base at kata.coderdojo.com"
msgstr "Contributing to Kata, the community knowledge base at kata.coderdojo.com"

msgid "Connecting with local and international Dojos to share insights and supports"
msgstr "Connecting with local and international Dojos to share insights and supports"

msgid "This dojo has no coordinates."
msgstr "This dojo has no coordinates."

Expand All @@ -2128,6 +2068,9 @@ msgstr "You have been invited to register as a parent/guardian on Zen, the Coder
msgid "CoderDojo Zen Password Reset Request"
msgstr "CoderDojo Zen Password Reset Request"

msgid "CoderDojo Zen Account Lockout"
msgstr "CoderDojo Zen Account Lockout"

msgid "You have been invited to connect with a parent/guardian on Zen!"
msgstr "You have been invited to connect with a parent/guardian on Zen!"

Expand Down Expand Up @@ -2179,9 +2122,6 @@ msgstr "Welcome New CoderDojo Champion!"
msgid "The first step towards setting up a Dojo in your area is filling out the form below and giving us a little more information about yourself."
msgstr "The first step towards setting up a Dojo in your area is filling out the form below and giving us a little more information about yourself."

msgid "The purpose of us gathering this information is so we can tailor support to you as your start your Dojo journey!"
msgstr "The purpose of us gathering this information is so we can tailor support to you as your start your Dojo journey!"

msgid "If you wish to learn more about the process of starting a CoderDojo in your area before completing this form please see Kata, the CoderDojo Community Knowledge Base."
msgstr "If you wish to learn more about the process of starting a CoderDojo in your area before completing this form please see Kata, the CoderDojo Community Knowledge Base."

Expand Down Expand Up @@ -2302,9 +2242,6 @@ msgstr "Parent profile does not exist."
msgid "You have a Dojo application awaiting verification. You can create another Dojo after it has been verified."
msgstr "You have a Dojo application awaiting verification. You can create another Dojo after it has been verified."

msgid "No Dojos match your search query."
msgstr "No Dojos match your search query."

msgid "Please let us know how you heard about CoderDojo"
msgstr "Please let us know how you heard about CoderDojo"

Expand Down Expand Up @@ -2578,9 +2515,6 @@ msgstr "My Events"
msgid "Review Champion Application"
msgstr "Review Champion Application"

msgid "Manage Dojo Users"
msgstr "Manage Dojo Users"

msgid "Setup Dojo"
msgstr "Setup Dojo"

Expand Down Expand Up @@ -3003,9 +2937,6 @@ msgstr "Changes to our Privacy Statement"
msgid "Any changes to this Privacy Statement will be posted on the Website so you are always aware of what information we collect, how we use it, and under what circumstances, if any, we disclose it. If at any time we decide to use personal data in a manner significantly different from that stated in this Privacy Statement, or otherwise disclosed to you at the time it was collected, we will notify you by email, and you will have a choice as to whether or not we use your information in the new manner."
msgstr "Any changes to this Privacy Statement will be posted on the Website so you are always aware of what information we collect, how we use it, and under what circumstances, if any, we disclose it. If at any time we decide to use personal data in a manner significantly different from that stated in this Privacy Statement, or otherwise disclosed to you at the time it was collected, we will notify you by email, and you will have a choice as to whether or not we use your information in the new manner."

msgid "Contact"
msgstr "Contact"

msgid "We welcome any queries, comments or requests you may have regarding this Privacy Statement. Please contact us in writing at Dogpatch Labs, The CHQ Building, Custom House Quay, Dublin 1, IRELAND or by e-mail at [email protected]."
msgstr "We welcome any queries, comments or requests you may have regarding this Privacy Statement. Please contact us in writing at Dogpatch Labs, The CHQ Building, Custom House Quay, Dublin 1, IRELAND or by e-mail at [email protected]."

Expand Down Expand Up @@ -3052,4 +2983,4 @@ msgid "Are you sure you want to remove this child?"
msgstr "Are you sure you want to remove this child?"

msgid "A new dojo has been created"
msgstr "A new dojo has been created!"
msgstr "A new dojo has been created!"

0 comments on commit 2718b26

Please sign in to comment.