summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannik Schönartz2021-07-13 16:45:40 +0200
committerJannik Schönartz2021-07-13 16:45:40 +0200
commitf6966ee8ced5c7b41bd1a1324868c1b3fd612027 (patch)
tree7d8be0a8b7804ebc1c089dcb8eb61b7c814d86b8
parent[server/registration] Small edid parse bugfix (diff)
downloadbas-f6966ee8ced5c7b41bd1a1324868c1b3fd612027.tar.gz
bas-f6966ee8ced5c7b41bd1a1324868c1b3fd612027.tar.xz
bas-f6966ee8ced5c7b41bd1a1324868c1b3fd612027.zip
[server/idoit/registration] Change contact from name / lastname to username & cut netmask from ip
-rw-r--r--server/api/registration.js9
-rw-r--r--server/lib/external-backends/backends/idoit-backend.js17
2 files changed, 11 insertions, 15 deletions
diff --git a/server/api/registration.js b/server/api/registration.js
index 1b5a6d1..5d161b7 100644
--- a/server/api/registration.js
+++ b/server/api/registration.js
@@ -683,12 +683,15 @@ async function parseHardwareInformation (data) {
/* Get network information as fallback for ip */
if (client.networks.length <= 0) {
for (let key in data.net) {
+ // IP v4 and v6 comes with the netmask, so the last 3 chars need to be cut
+ const ipv4 = data.net[key]['ipv4']
+ const ipv6 = data.net[key]['ipv6']
let network = {
'name': key,
'mac': data.net[key]['mac'],
- 'ip': data.net[key]['ipv4'],
- 'ipv6': data.net[key]['ipv6'],
- 'hostname': ''
+ ...(ipv4 && { 'ip': ipv4.substring(0, ipv4.length - 3) }),
+ ...(ipv6 && { 'ipv6': ipv6.substring(0, ipv6.length - 3) }),
+ 'hostname': undefined
}
client.networks.push(network)
}
diff --git a/server/lib/external-backends/backends/idoit-backend.js b/server/lib/external-backends/backends/idoit-backend.js
index 2b5462c..c538a31 100644
--- a/server/lib/external-backends/backends/idoit-backend.js
+++ b/server/lib/external-backends/backends/idoit-backend.js
@@ -343,6 +343,7 @@ class IdoitBackend extends ExternalBackends {
'cmdb.objects.read',
{
'apikey': c.apikey,
+ 'categories': ['C__CATS__PERSON'],
'filter': {
'type': 'C__OBJTYPE__PERSON'
}
@@ -360,19 +361,11 @@ class IdoitBackend extends ExternalBackends {
const persons = boundObjects.filter(response => response.id.startsWith('READ_C__OBJTYPE__PERSON'))[0].result
let counter = 0
- // Helper method for replaceing ä -> ae, ü -> ue, ö -> oe
- const replaceUmlauts = input => {
- return input.toLowerCase().replace(/\u00e4/g, 'ae').replace(/\u00fc/g, 'ue').replace(/\u00f6/g, 'oe')
- }
-
- for (let contact of client.contacts) {
- const firstname = replaceUmlauts(contact.firstname)
- const lastname = replaceUmlauts(contact.lastname)
-
+ for (let username of client.contacts) {
const contactPerson = persons.filter(person => {
- if (!replaceUmlauts(person.title).includes(firstname)) return false
- else if (!replaceUmlauts(person.title).includes(lastname)) return false
- return true
+ // Check for the username
+ if (person.categories.C__CATS__PERSON[0].title === username) return true
+ return false
})
let contactId