-
Notifications
You must be signed in to change notification settings - Fork 117
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
Added authentication type to the ImportUsers tool #210
Open
eugen-mueller
wants to merge
2
commits into
Geotab:master
Choose a base branch
from
eugen-mueller:SOLENG-9478
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,16 @@ <h3>Import users</h3> | |
<input id="import-password" type="password" placeholder="Minimum of 8 characters" maxlength="255" /> | ||
<label style="font-size: 14px; margin-top: 10px;"><input id="import-password-reset" style="float:none" type="checkbox" title="This user will need to enter a new password the first time they log in to the database.">Force password change on next login</label> | ||
</p> | ||
<p> | ||
|
||
<label for="import-authType">Authentication Type</label> | ||
|
||
<select name="authType" id="import-authType" style="height: 33px;"> | ||
<option value="BasicAuthentication">Basic Authentication</option> | ||
</select> | ||
<select id="import-authType-certificate" data-placeholder="Select user certificate" style="height: 33px; display:none;"></select> | ||
</p> | ||
|
||
<p> | ||
<label for="import-groups">Groups</label> | ||
<select id="import-groups" multiple data-placeholder="Select groups"></select> | ||
|
@@ -765,6 +775,7 @@ <h2>Help</h2> | |
var passwordResetCheckbox = document.getElementById("import-password-reset"); | ||
var hosRulesetArray = []; | ||
var moreCalls = []; | ||
var certificates = {}; | ||
|
||
function toggleDocs(event) { | ||
|
||
|
@@ -800,8 +811,8 @@ <h2>Help</h2> | |
groupCache = refreshGroupCache(null); | ||
securityClearanceCache = refreshSecurityClearanceCache(null); | ||
timeZoneCache = refreshTimeZoneCache(null); | ||
getCertificates(null); | ||
document.getElementById("content").addEventListener("keyup", function(event) { | ||
event.preventDefault(); | ||
|
||
|
@@ -914,10 +925,10 @@ <h2>Help</h2> | |
newContent += user.phoneNumberExtension + ","; | ||
newContent += user.designation + ","; | ||
newContent += user.employeeNo + ","; | ||
newContent += user.fuelEconomyUnit + ","; | ||
newContent += user.fuelEconomyUnit + ","; //16 | ||
newContent += user.isMetric + ","; | ||
newContent += user.isLabsEnabled + ","; | ||
newContent += user.timeZoneId + ","; | ||
newContent += user.timeZoneId + ","; // 19 | ||
newContent += user.authorityName + ","; | ||
newContent += user.authorityAddress + ","; | ||
newContent += user.carrierNumber + ","; | ||
|
@@ -927,7 +938,9 @@ <h2>Help</h2> | |
newContent += user.licenseProvince + ","; | ||
newContent += user.hosRuleSet + ","; | ||
newContent += user.isYardMoveEnabled + ","; | ||
newContent += user.isPersonalConveyanceEnabled; | ||
newContent += user.isPersonalConveyanceEnabled + ","; | ||
newContent += user.userAuthenticationType + ","; | ||
newContent += user.userSelectedCertificate; | ||
|
||
document.getElementById("content").value = newContent; | ||
document.getElementById("importUsers").disabled = false; | ||
|
@@ -958,8 +971,8 @@ <h2>Help</h2> | |
|
||
for (i = 0; i < users.length; i++) { | ||
var split = users[i].split(","); | ||
|
||
if (split.length !== 28) { | ||
if (split.length !== 30) { | ||
alert("Missing necessary information from user: " + users[i]); | ||
continue; | ||
} | ||
|
@@ -990,7 +1003,9 @@ <h2>Help</h2> | |
var licenseProvince = split[24]; | ||
var hosRuleSet = split[25]; | ||
var isYardMoveEnabled = split[26]; | ||
var isPersonalConveyanceEnabled = split[27]; | ||
var isPersonalConveyanceEnabled = split[27]; | ||
var userAuthenticationType = split[28]; | ||
var userSelectedCertificate = split[29]; | ||
|
||
// when pasting in ',' seperated string make sure values aren't empty | ||
if (isYardMoveEnabled === '') { | ||
|
@@ -1008,7 +1023,7 @@ <h2>Help</h2> | |
companyGroups: groups, | ||
reportGroups: reportGroups, | ||
securityGroups: securityGroups, | ||
userAuthenticationType: "BasicAuthentication", | ||
userAuthenticationType: userAuthenticationType, | ||
activeFrom: new Date().toISOString(), | ||
activeTo: "2050-01-01T00:00:00.000Z", | ||
countryCode: countryCode, | ||
|
@@ -1030,6 +1045,14 @@ <h2>Help</h2> | |
isYardMoveEnabled: isYardMoveEnabled, | ||
isPersonalConveyanceEnabled: isPersonalConveyanceEnabled | ||
}; | ||
|
||
if (newUser.userAuthenticationType == 'SAML') { | ||
|
||
newUser.issuerCertificate = { | ||
id: userSelectedCertificate, | ||
isRoot: certificates[userSelectedCertificate].isRoot | ||
}; | ||
} | ||
|
||
if (keys.length > 0){ | ||
newUser.driverGroups = groups; | ||
|
@@ -1056,7 +1079,7 @@ <h2>Help</h2> | |
} | ||
]); | ||
} | ||
|
||
api.multiCall(calls, function(results) { | ||
var userIds = results; | ||
pushRulesets(userIds); | ||
|
@@ -1104,6 +1127,7 @@ <h2>Help</h2> | |
} | ||
} | ||
} | ||
|
||
} | ||
}); | ||
|
||
|
@@ -1179,8 +1203,16 @@ <h2>Help</h2> | |
var isPersonalConveyanceEnabled = true; | ||
} else { | ||
var isPersonalConveyanceEnabled = false; | ||
} | ||
} | ||
|
||
var selectedAuthType = document.getElementById("import-authType").value; | ||
|
||
if (selectedAuthType == 'SAML') { | ||
var selectedCertificate = document.getElementById("import-authType-certificate").value; | ||
} else { | ||
var selectedCertificate = null; | ||
} | ||
|
||
return { | ||
userName: document.getElementById("import-userName").value, | ||
firstName: document.getElementById("import-firstName").value, | ||
|
@@ -1209,7 +1241,9 @@ <h2>Help</h2> | |
licenseProvince: plateState, | ||
hosRuleSet: document.getElementById("options_hosRuleSet").value, | ||
isYardMoveEnabled: isYardMoveEnabled, | ||
isPersonalConveyanceEnabled: isPersonalConveyanceEnabled | ||
isPersonalConveyanceEnabled: isPersonalConveyanceEnabled, | ||
userAuthenticationType: selectedAuthType, | ||
userSelectedCertificate: selectedCertificate | ||
} | ||
} | ||
|
||
|
@@ -1307,6 +1341,58 @@ <h2>Help</h2> | |
console.log(error); | ||
}); | ||
} | ||
|
||
|
||
function getCertificates(callback) { | ||
var selectAuthType = document.getElementById("import-authType"); | ||
var select = document.getElementById("import-authType-certificate"); | ||
|
||
document.getElementById("import-authType").addEventListener('change', function(event) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this event listener should be lumped in with the getCertificates method? |
||
|
||
if (event.target.value == 'SAML'){ | ||
select.style.display = ''; | ||
} else { | ||
select.style.display = 'none'; | ||
} | ||
|
||
}); | ||
|
||
api.call("Get", { | ||
"typeName":"Certificate" | ||
}, function(result) { | ||
if (result !== undefined && result != null && result.length > 0) { | ||
|
||
for (i = 0; i < result.length; i++) { | ||
|
||
var option = new Option(); | ||
option.text = result[i].issuer; | ||
option.value = result[i].id; | ||
select.add(option); | ||
|
||
certificates[result[i].id] = { | ||
name: result[i].issuer, | ||
id : result[i].id, | ||
isRoot: result[i].isRoot | ||
}; | ||
} | ||
|
||
var option = new Option(); | ||
option.text = "SAML"; | ||
option.value = "SAML"; | ||
selectAuthType.add(option); | ||
|
||
select.style.display = 'none'; | ||
//return certificates; | ||
|
||
} | ||
if (callback) { | ||
callback(); | ||
} | ||
}, function(error) { | ||
console.log(error); | ||
}); | ||
} | ||
|
||
|
||
function refreshGroupCache(callback) { | ||
var select = document.getElementById("import-groups"); | ||
|
Binary file modified
BIN
+59.2 KB
(110%)
src/software/js-samples/templates/import-users-template.xlsx
Binary file not shown.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation looks off here.
Should use
===
in js?