Skip to content

Commit

Permalink
Fix uri params with spaces (#347)
Browse files Browse the repository at this point in the history
Parent issue: sequentech/meta#260
  • Loading branch information
edulix committed Sep 30, 2023
1 parent f9ed81c commit 1d698b5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
27 changes: 26 additions & 1 deletion avRegistration/login-directive/login-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,9 @@ angular.module('avRegistration')

scope.getUriParam = function (paramName) {
var uri = $window.location.href;
var paramName2 = paramName.replace(/[\[\]]/g, '\\$&');
var paramName2 = paramName
.replace(/[\[\]]/g, '\\$&')
.replace(/ /g, '%20');
var rx = new RegExp('[?&]' + paramName2 + '(=([^&#]*)|&|#|$)');
var params = rx.exec(uri);

Expand Down Expand Up @@ -658,6 +660,29 @@ angular.module('avRegistration')
return el;
});

// if all the login fields required on authentication that are not
// of type code have been filled and we are in email-otp or sms-otp,
// we should enable jump to currantFormStep = 1. Normally this
// already happened, but it could be that it didn't if the main
// extra_field is hidden
if (
scope.currentFormStep === 0 &&
_.contains(['email-otp', 'sms-otp'], scope.auth_method)
) {
var unfilledFields = _.filter(
fields,
function (el) {
return (
el.value === null &&
!_.contains(['otp-code', 'code'], el.type)
);
}
);
if (unfilledFields.length === 0) {
scope.currentFormStep = 1;
}
}

// if not all the fields all filled at this point, then we stop
// here. otp-code fields do not count, because loginUser
// function will send the appropiate OTP code if required
Expand Down
6 changes: 4 additions & 2 deletions dist/appCommon-v10.0.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
});
}))) : scope.resendAuthCode()));
}, scope.getUriParam = function(paramName2) {
var params = $window.location.href, paramName2 = paramName2.replace(/[\[\]]/g, "\\$&"), params = new RegExp("[?&]" + paramName2 + "(=([^&#]*)|&|#|$)").exec(params);
var params = $window.location.href, paramName2 = paramName2.replace(/[\[\]]/g, "\\$&").replace(/ /g, "%20"), params = new RegExp("[?&]" + paramName2 + "(=([^&#]*)|&|#|$)").exec(params);
return params ? params[2] ? decodeURIComponent(params[2].replace(/\+/g, " ")) || void 0 : "" : null;
}, scope.getAltAuthMethodName = function(altAuthMethod) {
var langCode = $window.i18n.lng();
Expand Down Expand Up @@ -616,7 +616,9 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
el.disabled = !0) : "user_id" === el.name && "smart-link" === scope.method && (el.value = scope.user_id,
el.disabled = !0), el;
});
_.filter(fields, function(el) {
0 === scope.currentFormStep && _.contains([ "email-otp", "sms-otp" ], scope.auth_method) && 0 === _.filter(fields, function(el) {
return null === el.value && !_.contains([ "otp-code", "code" ], el.type);
}).length && (scope.currentFormStep = 1), _.filter(fields, function(el) {
return null !== el.value || "otp-code" === el.type;
}).length === scope.login_fields.length && ("openid-connect" === scope.method || scope.isOtl || scope.isCensusQuery || scope.withCode || scope.loginUser(!0));
}, scope.view = function(id) {
Expand Down

0 comments on commit 1d698b5

Please sign in to comment.