Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge features into 7.1.x #250

Merged
merged 5 commits into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions SequentConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ var SequentConfigData = {
// Allowed values: true|false
allowEditElectionJson: true,

// For admins:
// Allow sending custom html in the email messages sent from the admin console.
// Allowed values: true|false
allowHtmlEmails: false,

// For admins:
// Allow editing the election.presentation.theme_css so that any election
// Admin can highly customize the election directly with CSS.
Expand Down
31 changes: 28 additions & 3 deletions avRegistration/auth-method-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,20 @@ angular.module('avRegistration')
return fields;
};

authmethod.hasOtpCodeField = function (viewEventData)
{
var fields = authmethod.getRegisterFields(
viewEventData
);
for (var i=0; i<fields.length; i++) {
if (fields[i]['type'] === "otp-code") {
return true;
}
}

return false;
};

authmethod.getCensusQueryFields = function (viewEventData)
{
var fields = angular.copy(viewEventData.extra_fields);
Expand Down Expand Up @@ -444,6 +458,8 @@ angular.module('avRegistration')
var fields = authmethod.getRegisterFields(
viewEventData
);
var hasOtpCodeField = authmethod.hasOtpCodeField(viewEventData);

if (_.contains(["sms", "email"], viewEventData.auth_method))
{
fields.push({
Expand All @@ -452,8 +468,10 @@ angular.module('avRegistration')
"required": true,
"required_on_authentication": true
});
} else if (_.contains(["sms-otp", "email-otp"], viewEventData.auth_method))
{
} else if (
hasOtpCodeField ||
_.contains(["sms-otp", "email-otp"], viewEventData.auth_method)
) {
fields.push({
"name": "code",
"type": "code",
Expand All @@ -463,7 +481,10 @@ angular.module('avRegistration')
});
}

fields = _.filter(fields, function (field) {return field.required_on_authentication;});
fields = _.filter(
fields,
function (field) {return field.required_on_authentication;}
);

// put captha the last
for (var i=0; i<fields.length; i++) {
Expand Down Expand Up @@ -550,6 +571,10 @@ angular.module('avRegistration')
data.msg = election.census.config.msg;
if ('email' === auth_method) {
data.subject = election.census.config.subject;
if (ConfigService.allowHtmlEmails &&
election.census.config.html_message) {
data.html_message = election.census.config.html_message;
}
}
}
if (angular.isDefined(user_ids)) {
Expand Down
68 changes: 54 additions & 14 deletions avRegistration/login-directive/login-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,28 @@ angular.module('avRegistration')
// if invalid method or already sending data, do not proceed
if (
scope.sendingData ||
!_.contains(["email", "email-otp", "sms", "sms-otp"], scope.method)
!(
scope.hasOtpFieldsCode ||
_.contains(["email", "email-otp", "sms", "sms-otp"], scope.method)
)
) {
return;
}

// if telIndex or emailIndex not set when needed, do not proceed
if (
(
_.contains(["sms", "sms-otp"], scope.method) &&
scope.telIndex === -1 &&
!scope.hide_default_login_lookup_field
) || (
_.contains(["email", "email-otp"], scope.method) &&
scope.emailIndex === -1 &&
!scope.hide_default_login_lookup_field
!scope.hasOtpFieldsCode &&
(
(
_.contains(["sms", "sms-otp"], scope.method) &&
scope.telIndex === -1 &&
!scope.hide_default_login_lookup_field
) ||
(
_.contains(["email", "email-otp"], scope.method) &&
scope.emailIndex === -1 &&
!scope.hide_default_login_lookup_field
)
)
) {
return;
Expand Down Expand Up @@ -194,6 +201,18 @@ angular.module('avRegistration')
scope.sendingData = false;
};

scope.parseAuthToken = function () {
if (scope.method !== 'smart-link') {
return;
}
scope.authToken = $location.search()['auth-token'];

var length = 'khmac:///'.length;
var tails = scope.authToken.substr(length);
var message = tails.split('/')[1];
scope.user_id = message.split(':')[0];
};

scope.checkCensus = function(valid) {
if (!valid) {
return;
Expand Down Expand Up @@ -237,7 +256,10 @@ angular.module('avRegistration')
// loginUser
if (
!scope.withCode &&
_.contains(['sms-otp', 'email-otp'], scope.method) &&
(
scope.hasOtpFieldsCode ||
_.contains(['sms-otp', 'email-otp'], scope.method)
) &&
scope.currentFormStep === 0
) {
scope.resendAuthCode();
Expand Down Expand Up @@ -372,8 +394,10 @@ angular.module('avRegistration')
};

scope.apply = function(authevent) {
scope.hasOtpFieldsCode = Authmethod.hasOtpCodeField(authevent);
scope.method = authevent['auth_method'];
scope.name = authevent['name'];
scope.parseAuthToken();
scope.registrationAllowed = (
(authevent['census'] === 'open') &&
(autheventid !== adminId || ConfigService.allowAdminRegistration)
Expand Down Expand Up @@ -448,14 +472,30 @@ angular.module('avRegistration')
} else if (el.name === '__username' && scope.withCode) {
el.value = scope.username;
el.disabled = true;
} else if (
el.name === 'user_id' &&
scope.method === 'smart-link'
) {
el.value = scope.user_id;
el.disabled = true;
}
return el;
});
var filled_fields = _.filter(fields,
function (el) { return el.value !== null; });

// if not all the fields all filled at this point, then we stop here
if (filled_fields.length !== scope.login_fields.length) {
// if not all the fields all filled at this point, then we stop
// here. otp-code or code fields do not count, because loginUser
// function will send the appropiate OTP code if required
var filledFields = _.filter(
fields,
function (el) {
return (
el.value !== null ||
el.type === 'otp-code' ||
el.type === 'code'
);
}
);
if (filledFields.length !== scope.login_fields.length) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion avUi/foot-directive/foot-directive.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[av-foot] {
.commonfoot {
padding: 40px 0 200px 0;
padding: 40px 0;
background-color: @av-bg;
}

Expand Down
5 changes: 5 additions & 0 deletions dist/SequentConfig-v7.0.0-beta.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ var SequentConfigData = {
// Allowed values: true|false
allowEditElectionJson: true,

// For admins:
// Allow sending custom html in the email messages sent from the admin console.
// Allowed values: true|false
allowHtmlEmails: false,

// For admins:
// Allow editing the election.presentation.theme_css so that any election
// Admin can highly customize the election directly with CSS.
Expand Down
30 changes: 21 additions & 9 deletions dist/appCommon-v7.0.0-beta.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
}
return fields;
},
hasOtpCodeField: function(viewEventData) {
for (var fields = authmethod.getRegisterFields(viewEventData), i = 0; i < fields.length; i++) if ("otp-code" === fields[i].type) return !0;
return !1;
},
getCensusQueryFields: function(fields) {
fields = angular.copy(fields.extra_fields);
return fields = _.filter(fields, function(field) {
Expand All @@ -230,13 +234,13 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
} ];
},
getLoginFields: function(viewEventData) {
var fields = authmethod.getRegisterFields(viewEventData);
var fields = authmethod.getRegisterFields(viewEventData), hasOtpCodeField = authmethod.hasOtpCodeField(viewEventData);
_.contains([ "sms", "email" ], viewEventData.auth_method) ? fields.push({
name: "code",
type: "code",
required: !0,
required_on_authentication: !0
}) : _.contains([ "sms-otp", "email-otp" ], viewEventData.auth_method) && fields.push({
}) : (hasOtpCodeField || _.contains([ "sms-otp", "email-otp" ], viewEventData.auth_method)) && fields.push({
name: "code",
type: "code",
required: !0,
Expand Down Expand Up @@ -277,7 +281,8 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
},
sendAuthCodes: function(data, election, user_ids, auth_method, extra, filter) {
var url = backendUrl + "auth-event/" + data + "/census/send_auth/", data = {};
return angular.isDefined(election) && (data.msg = election.census.config.msg, "email" === auth_method && (data.subject = election.census.config.subject)),
return angular.isDefined(election) && (data.msg = election.census.config.msg, "email" === auth_method && (data.subject = election.census.config.subject,
ConfigService.allowHtmlEmails && election.census.config.html_message && (data.html_message = election.census.config.html_message))),
angular.isDefined(user_ids) && (data["user-ids"] = user_ids), angular.isDefined(auth_method) && (data["auth-method"] = auth_method),
extra && (data.extra = extra), angular.isDefined(filter) && (data.filter = filter),
$http.post(url, data);
Expand Down Expand Up @@ -425,7 +430,7 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
scope.email = null, attrs.email && 0 < attrs.email.length && (scope.email = attrs.email),
scope.isAdmin = !1, autheventid === adminId && (scope.isAdmin = !0), scope.resendAuthCode = function(field) {
var stop, data;
!scope.sendingData && _.contains([ "email", "email-otp", "sms", "sms-otp" ], scope.method) && (_.contains([ "sms", "sms-otp" ], scope.method) && -1 === scope.telIndex && !scope.hide_default_login_lookup_field || _.contains([ "email", "email-otp" ], scope.method) && -1 === scope.emailIndex && !scope.hide_default_login_lookup_field || (stop = !1,
scope.sendingData || !scope.hasOtpFieldsCode && !_.contains([ "email", "email-otp", "sms", "sms-otp" ], scope.method) || !scope.hasOtpFieldsCode && (_.contains([ "sms", "sms-otp" ], scope.method) && -1 === scope.telIndex && !scope.hide_default_login_lookup_field || _.contains([ "email", "email-otp" ], scope.method) && -1 === scope.emailIndex && !scope.hide_default_login_lookup_field) || (stop = !1,
data = _.object(_.filter(scope.login_fields, function(element, index) {
return element.index = index, void 0 === element.steps || -1 !== element.steps.indexOf(0);
}).map(function(element) {
Expand All @@ -440,9 +445,14 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
}), scope.currentFormStep = 1, scope.error = null, $timeout(scope.sendingDataTimeout, 3e3);
}, function(response) {
$timeout(scope.sendingDataTimeout, 3e3), scope.error = $i18next("avRegistration.errorSendingAuthCode");
}))));
})));
}, scope.sendingDataTimeout = function() {
scope.sendingData = !1;
}, scope.parseAuthToken = function() {
var message;
"smart-link" === scope.method && (scope.authToken = $location.search()["auth-token"],
message = "khmac:///".length, message = scope.authToken.substr(message).split("/")[1],
scope.user_id = message.split(":")[0]);
}, scope.checkCensus = function(valid) {
var data;
valid && (scope.sendingData || (scope.censusQuery = "querying", data = {
Expand All @@ -456,7 +466,7 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
})));
}, scope.loginUser = function(valid) {
var data;
valid && (scope.sendingData || (scope.withCode || !_.contains([ "sms-otp", "email-otp" ], scope.method) || 0 !== scope.currentFormStep ? (data = {
valid && (scope.sendingData || (scope.withCode || !scope.hasOtpFieldsCode && !_.contains([ "sms-otp", "email-otp" ], scope.method) || 0 !== scope.currentFormStep ? (data = {
captcha_code: Authmethod.captcha_code
}, _.each(scope.login_fields, function(field) {
"email" === field.name ? scope.email = field.value : "code" === field.name && (field.value = field.value.trim().replace(/ |\n|\t|-|_/g, "").toUpperCase()),
Expand Down Expand Up @@ -505,7 +515,8 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
});
})) : scope.resendAuthCode()));
}, scope.apply = function(authevent) {
scope.method = authevent.auth_method, scope.name = authevent.name, scope.registrationAllowed = "open" === authevent.census && (autheventid !== adminId || ConfigService.allowAdminRegistration),
scope.hasOtpFieldsCode = Authmethod.hasOtpCodeField(authevent), scope.method = authevent.auth_method,
scope.name = authevent.name, scope.parseAuthToken(), scope.registrationAllowed = "open" === authevent.census && (autheventid !== adminId || ConfigService.allowAdminRegistration),
scope.isCensusQuery || scope.withCode ? scope.withCode ? scope.login_fields = Authmethod.getLoginWithCode(authevent) : scope.login_fields = Authmethod.getCensusQueryFields(authevent) : scope.login_fields = Authmethod.getLoginFields(authevent),
scope.hide_default_login_lookup_field = authevent.hide_default_login_lookup_field,
scope.telIndex = -1, scope.emailIndex = -1, scope.telField = null, scope.allowUserResend = function() {
Expand All @@ -521,11 +532,12 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
scope.emailIndex = index) : "code" === el.type && null !== scope.code ? (el.value = scope.code.trim().replace(/ |\n|\t|-|_/g, "").toUpperCase(),
el.disabled = !0) : "tlf" === el.type && "sms" === scope.method ? (null !== scope.email && -1 === scope.email.indexOf("@") && (el.value = scope.email,
el.disabled = !0), scope.telIndex = index + 1, scope.telField = el) : "tlf" === el.type && "sms-otp" === scope.method ? (null !== scope.email && -1 === scope.email.indexOf("@") && (el.value = scope.email,
el.disabled = !0, scope.currentFormStep = 1), scope.telIndex = index + 1, scope.telField = el) : "__username" === el.name && scope.withCode && (el.value = scope.username,
el.disabled = !0, scope.currentFormStep = 1), scope.telIndex = index + 1, scope.telField = el) : "__username" === el.name && scope.withCode ? (el.value = scope.username,
el.disabled = !0) : "user_id" === el.name && "smart-link" === scope.method && (el.value = scope.user_id,
el.disabled = !0), el;
});
_.filter(fields, function(el) {
return null !== el.value;
return null !== el.value || "otp-code" === el.type || "code" === el.type;
}).length === scope.login_fields.length && "openid-connect" !== scope.method && scope.loginUser(!0);
}, scope.view = function(id) {
Authmethod.viewEvent(id).then(function(response) {
Expand Down
2 changes: 1 addition & 1 deletion dist/less/avUi/foot-directive/foot-directive.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[av-foot] {
.commonfoot {
padding: 40px 0 200px 0;
padding: 40px 0;
background-color: @av-bg;
}

Expand Down
10 changes: 5 additions & 5 deletions dist/libCommon-v7.0.0-beta.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -1959,7 +1959,7 @@ function RNG(seed) {
}
function minErr(module, ErrorConstructor) {
ErrorConstructor = ErrorConstructor || Error;
var url = "https://errors.angularjs.org/1.8.2/", regex = url.replace(".", "\\.") + "[\\s\\S]*", errRegExp = new RegExp(regex, "g");
var url = "https://errors.angularjs.org/1.8.3/", regex = url.replace(".", "\\.") + "[\\s\\S]*", errRegExp = new RegExp(regex, "g");
return function() {
var paramPrefix, i, code = arguments[0], template = arguments[1], message = "[" + (module ? module + ":" : "") + code + "] ", templateArgs = sliceArgs(arguments, 2).map(function(arg) {
return toDebugString(arg, minErrConfig.objectMaxDepth);
Expand Down Expand Up @@ -2491,11 +2491,11 @@ function RNG(seed) {
}(obj, maxDepth) : obj;
}
var version = {
full: "1.8.2",
full: "1.8.3",
major: 1,
minor: 8,
dot: 2,
codeName: "meteoric-mining"
dot: 3,
codeName: "ultimate-farewell"
};
JQLite.expando = "ng339";
var jqCache = JQLite.cache = {}, jqId = 1;
Expand Down Expand Up @@ -9490,7 +9490,7 @@ function RNG(seed) {
$$cookieReader: $$CookieReaderProvider
});
} ]).info({
angularVersion: "1.8.2"
angularVersion: "1.8.3"
});
}(angular), angular.module("ngLocale", [], [ "$provide", function($provide) {
var PLURAL_CATEGORY_ONE = "one", PLURAL_CATEGORY_OTHER = "other";
Expand Down
2 changes: 1 addition & 1 deletion dist/themes/bcnencomu/app.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/themes/cup/app.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/themes/default/app.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/themes/diba/app.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/themes/ebcn/app.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/themes/helsinki/app.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/themes/loop/app.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/themes/podemos/app.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/themes/test/app.min.css

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@bower_components/ng-i18next": "i18next/ng-i18next#0.4.2",
"@bower_components/ngInfiniteScroll": "sroze/ngInfiniteScroll#1.2.0",
"@lodder/grunt-postcss": "^3.0.0",
"angular": "~1.8.0",
"angular": "~1.8.3",
"angular-animate": "~1.8.0",
"angular-cookie": "~4.0.9",
"angular-cookies": "~1.8.0",
Expand Down Expand Up @@ -92,6 +92,7 @@
"**/lodash": "^4.17.21",
"**/hosted-git-info": "3.0.8",
"**/minimist": "1.2.6",
"**/moment": "2.29.4",
"**/yargs-parser": "13.1.2",
"**/cheerio": "0.12.3",
"**/cheerio-select": "0.0.3",
Expand Down
Loading