Skip to content

Commit

Permalink
changing credential storage to store all the credentials without filt…
Browse files Browse the repository at this point in the history
…ering, as required by new election chooser in voting booth, and redirecting to parent election (#169)

* changing credential storage to store all the credentials without filtering, as required by new election chooser in voting booth, and redirecting to parent election

* allowing to hide parent in children-election info widget

* simplifying redirection to voting booth
  • Loading branch information
edulix authored Nov 16, 2021
1 parent 02e01c4 commit 71c12cc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 25 deletions.
19 changes: 4 additions & 15 deletions avRegistration/login-directive/login-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,18 +316,14 @@ angular.module('avRegistration')
// assumes the authapi response has the same children
var tokens = _
.chain(response.data['vote-children-info'])
.filter(function (child) {
return (
child['num-successful-logins-allowed'] === 0 ||
child['num-successful-logins'] < child['num-successful-logins-allowed']
) && !!child['vote-permission-token'];
})
.map(function (child, index) {
return {
electionId: child['auth-event-id'],
token: child['vote-permission-token'],
token: child['vote-permission-token'] || null,
skipped: false,
voted: false,
numSuccessfulLoginsAllowed: child['num-successful-logins-allowed'],
numSuccessfulLogins: child['num-successful-logins'],
isFirst: index === 0
};
})
Expand All @@ -337,14 +333,7 @@ angular.module('avRegistration')
JSON.stringify(tokens)
);

if (tokens.length > 0) {
$window.location.href = '/booth/' + tokens[0].electionId + '/vote';
} else {
scope.error = $i18next(
'avRegistration.invalidCredentials',
{support: ConfigService.contact.email}
);
}
$window.location.href = '/booth/' + autheventid + '/vote';
} else {
scope.error = $i18next(
'avRegistration.invalidCredentials',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div
class="row"
ng-if="mode === 'toggle-and-callback'"
ng-if="mode === 'toggle-and-callback' && !hideParent"
>
<div class="col-xs-12">
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ angular.module('avUi')
{
scope.electionsById = {};
scope.selectedElectionId = scope.parentElectionId;
scope.hideParent = (attrs.hideParent === 'true');

// process each election
_.each(
Expand Down
17 changes: 8 additions & 9 deletions dist/appCommon-vmaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,20 +447,18 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
}) : angular.isDefined(tokens.data["redirect-to-url"]) ? $window.location.href = tokens.data["redirect-to-url"] : angular.isDefined(tokens.data["vote-permission-token"]) ? ($window.sessionStorage.setItem("vote_permission_tokens", JSON.stringify([ {
electionId: autheventid,
token: tokens.data["vote-permission-token"]
} ])), $window.location.href = "/booth/" + autheventid + "/vote") : angular.isDefined(tokens.data["vote-children-info"]) ? (tokens = _.chain(tokens.data["vote-children-info"]).filter(function(child) {
return (0 === child["num-successful-logins-allowed"] || child["num-successful-logins"] < child["num-successful-logins-allowed"]) && !!child["vote-permission-token"];
}).map(function(child, index) {
} ])), $window.location.href = "/booth/" + autheventid + "/vote") : angular.isDefined(tokens.data["vote-children-info"]) ? (tokens = _.chain(tokens.data["vote-children-info"]).map(function(child, index) {
return {
electionId: child["auth-event-id"],
token: child["vote-permission-token"],
token: child["vote-permission-token"] || null,
skipped: !1,
voted: !1,
numSuccessfulLoginsAllowed: child["num-successful-logins-allowed"],
numSuccessfulLogins: child["num-successful-logins"],
isFirst: 0 === index
};
}).value(), $window.sessionStorage.setItem("vote_permission_tokens", JSON.stringify(tokens)),
0 < tokens.length ? $window.location.href = "/booth/" + tokens[0].electionId + "/vote" : scope.error = $i18next("avRegistration.invalidCredentials", {
support: ConfigService.contact.email
})) : scope.error = $i18next("avRegistration.invalidCredentials", {
$window.location.href = "/booth/" + autheventid + "/vote") : scope.error = $i18next("avRegistration.invalidCredentials", {
support: ConfigService.contact.email
})) : (scope.sendingData = !1, scope.status = "Not found", scope.error = $i18next("avRegistration.invalidCredentials", {
support: ConfigService.contact.email
Expand Down Expand Up @@ -911,7 +909,8 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
childrenElectionInfo: "="
},
link: function(scope, element, attrs) {
scope.electionsById = {}, scope.selectedElectionId = scope.parentElectionId, _.each(scope.childrenElectionInfo.presentation.categories, function(category) {
scope.electionsById = {}, scope.selectedElectionId = scope.parentElectionId, scope.hideParent = "true" === attrs.hideParent,
_.each(scope.childrenElectionInfo.presentation.categories, function(category) {
_.each(category.events, function(election) {
"checkbox" !== scope.mode && "toggle-and-callback" !== scope.mode || (election.data = election.data || !1,
election.disabled = election.disabled || !1);
Expand Down Expand Up @@ -1451,7 +1450,7 @@ angular.module("avTest", []), angular.module("avTest").controller("UnitTestE2ECo
$templateCache.put("avRegistration/register-directive/register-directive.html", '<div class="container"><div class="row"><div class="col-sm-12"><h2 ng-if="!admin" class="registerheader" ng-i18next="avRegistration.registerHeader"></h2><h2 ng-if="admin" class="registerheader" ng-i18next="avRegistration.registerAdminHeader"></h2></div></div><div class="row"><div class="col-sm-6"><div ng-if="method == \'dnie\'"><a type="submit" class="btn btn-block btn-success" ng-i18next="avRegistration.registerButton" ng-href="{{ dnieurl }}/"></a></div><form ng-if="method != \'dnie\'" name="form" id="registerForm" role="form" class="form-horizontal"><div ng-repeat="field in register_fields" avr-field index="{{$index+1}}"></div><div class="col-sm-offset-4 col-sm-8 button-group"><div class="input-error"><div class="error text-danger" ng-if="error" ng-bind-html="error"></div></div><div class="input-warn"><span class="text-warning" ng-if="!form.$valid || sendingData" ng-i18next>avRegistration.fillValidFormText</span></div><button type="submit" class="btn btn-block btn-success" ng-i18next="avRegistration.registerButton" ng-click="signUp(form.$valid)" tabindex="{{register_fields.length+1}}" ng-disabled="!form.$valid || sendingData"></button></div></form></div><div class="col-sm-5 col-sm-offset-1 help-sidebar hidden-xs"><span ng-if="admin"><h3 class="help-h3" ng-i18next="avRegistration.registerAdminFormHelpTitle"></h3><p ng-i18next>avRegistration.helpAdminRegisterForm</p></span><span><p ng-if="!admin" ng-i18next>avRegistration.helpRegisterForm</p><h3 class="help-h3" ng-i18next="avRegistration.alreadyRegistered"></h3><p ng-i18next>[html]avRegistration.helpAlreadyRegisteredForm</p><a href="" ng-click="goLogin($event)" ng-i18next="avRegistration.loginHere"></a><br></span></div></div></div>'),
$templateCache.put("avRegistration/success.html", '<div av-success><p ng-i18next="avRegistration.successRegistration"></p></div>'),
$templateCache.put("avUi/change-lang-directive/change-lang-directive.html", '<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{ deflang }} <span class="caret"></span></a><ul class="dropdown-menu" role="menu"><li ng-repeat="lang in langs"><a role="menuitem" ng-click="changeLang(lang)" ng-space-click tabindex="0">{{lang}}</a></li></ul>'),
$templateCache.put("avUi/children-elections-directive/children-elections-directive.html", '<div class="row" ng-if="mode === \'toggle-and-callback\'"><div class="col-xs-12"><div class="btn btn-success btn-election" ng-class="{\'selected\': selectedElectionId === parentElectionId}" ng-click="click({event_id: parentElectionId})"><span ng-i18next>avAdmin.childrenElections.main</span></div></div></div><div ng-repeat="category in childrenElectionInfo.presentation.categories" class="row"><div class="col-xs-12"><h4>{{category.title}}</h4><div ng-repeat="election in category.events" class="btn btn-success btn-election" ng-disabled="election.disabled" ng-class="{\'selected\': selectedElectionId === election.event_id}" data-election-id="{{election.event_id}}" ng-click="click(election)"><i ng-if="mode === \'checkbox\'" class="fa-fw fa" ng-class="{\'fa-square-o\': !election.data, \'fa-check-square-o\': !!election.data}" aria-hidden="true"></i> {{election.title}}</div></div></div>'),
$templateCache.put("avUi/children-elections-directive/children-elections-directive.html", '<div class="row" ng-if="mode === \'toggle-and-callback\' && !hideParent"><div class="col-xs-12"><div class="btn btn-success btn-election" ng-class="{\'selected\': selectedElectionId === parentElectionId}" ng-click="click({event_id: parentElectionId})"><span ng-i18next>avAdmin.childrenElections.main</span></div></div></div><div ng-repeat="category in childrenElectionInfo.presentation.categories" class="row"><div class="col-xs-12"><h4>{{category.title}}</h4><div ng-repeat="election in category.events" class="btn btn-success btn-election" ng-disabled="election.disabled" ng-class="{\'selected\': selectedElectionId === election.event_id}" data-election-id="{{election.event_id}}" ng-click="click(election)"><i ng-if="mode === \'checkbox\'" class="fa-fw fa" ng-class="{\'fa-square-o\': !election.data, \'fa-check-square-o\': !!election.data}" aria-hidden="true"></i> {{election.title}}</div></div></div>'),
$templateCache.put("avUi/documentation-directive/documentation-directive.html", '<div><h2 class="text-center text-av-secondary" ng-i18next="avDocumentation.documentation.title"></h2><p ng-i18next="avDocumentation.documentation.first_line"></p><ul class="docu-ul"><li ng-if="!!documentation.faq"><a href="{{documentation.faq}}" target="_blank" ng-i18next="avDocumentation.documentation.faq"></a></li><li ng-if="!!documentation.overview"><a href="{{documentation.overview}}" target="_blank" ng-i18next="avDocumentation.documentation.overview"></a></li><li><a href="{{auths_url}}" target="_blank" ng-i18next="avDocumentation.documentation.authorities"></a></li><li ng-if="!!documentation.technical"><a href="{{documentation.technical}}" target="_blank" ng-i18next="avDocumentation.documentation.technical"></a></li><li ng-if="!!documentation.security_contact"><a href="{{documentation.security_contact}}" target="_blank" ng-i18next="avDocumentation.documentation.security_contact"></a></li></ul><div class="documentation-html-include" av-plugin-html ng-bind-html="documentation_html_include"></div></div>'),
$templateCache.put("avUi/foot-directive/foot-directive.html", '<div class="commonfoot"><div class="social" style="text-align: center;"><span class="powered-by pull-left" ng-i18next="[html:i18next]({url: organization.orgUrl, name: organization.orgName})avCommon.poweredBy"></span> <a href="{{social.facebook}}" target="_blank" ng-if="!!social.facebook" aria-label="Facebook"><i class="fa fa-fw fa-lg fa-facebook"></i></a> <a href="{{social.twitter}}" target="_blank" ng-if="!!social.twitter" aria-label="Twitter"><i class="fa fa-fw fa-lg fa-twitter"></i></a> <a href="{{social.googleplus}}" target="_blank" ng-if="!!social.googleplus" aria-label="Google Plus"><i class="fa fa-fw fa-lg fa-google-plus"></i></a> <a href="{{social.youtube}}" target="_blank" ng-if="!!social.youtube" aria-label="Youtube"><i class="fa fa-fw fa-lg fa-youtube-play"></i></a> <a href="{{social.github}}" target="_blank" ng-if="!!social.github" aria-label="Github"><i class="fa fa-fw fa-lg fa-github"></i></a></div></div>'),
$templateCache.put("avUi/simple-error-directive/simple-error-directive.html", '<div class="av-simple-error-title" ng-transclude></div>'),
Expand Down

0 comments on commit 71c12cc

Please sign in to comment.