diff --git a/server/src/utils/activedirectory/entryParser.js b/server/src/utils/activedirectory/entryParser.js index 7827346..c6387fb 100755 --- a/server/src/utils/activedirectory/entryParser.js +++ b/server/src/utils/activedirectory/entryParser.js @@ -5,25 +5,42 @@ const entryParser = (entry, raw, callback) => { )}` if (raw.hasOwnProperty('pwdLastSet')) - entry.pwdLastSet = ldapTimeToJSTime(raw.pwdLastSet) + entry.pwdLastSet = ldapTimeToJSDate(raw.pwdLastSet) if (raw.hasOwnProperty('badPasswordTime')) - entry.badPasswordTime = ldapTimeToJSTime(raw.badPasswordTime) + entry.badPasswordTime = ldapTimeToJSDate(raw.badPasswordTime) if (raw.hasOwnProperty('lastLogon')) - entry.lastLogon = ldapTimeToJSTime(raw.lastLogon) + entry.lastLogon = ldapTimeToJSDate(raw.lastLogon) if (raw.hasOwnProperty('lastLogonTimestamp')) - entry.lastLogonTimestamp = ldapTimeToJSTime(raw.lastLogonTimestamp) + entry.lastLogonTimestamp = ldapTimeToJSDate(raw.lastLogonTimestamp) if (raw.hasOwnProperty('lockoutTime') && entry.lockoutTime !== '0') - entry.lockoutTime = ldapTimeToJSTime(raw.lockoutTime) + entry.lockoutTime = ldapTimeToJSDate(raw.lockoutTime) + + if (raw.hasOwnProperty('extensionAttribute7')) + entry.extensionAttribute7 = simpleDateToDate(entry.extensionAttribute7) callback(entry) } -function ldapTimeToJSTime(ldapTime) { +function ldapTimeToJSDate(ldapTime) { return new Date(ldapTime / 1e4 - 1.16444736e13) } +function simpleDateToDate(simpleDate) { + // Accepts a yyyymmdd day and converts to Date + + const year = simpleDate.substring(0, 4) + const month = simpleDate.substring(4, 6) + const day = simpleDate.substring(6, 8) + + const date = new Date(year, month - 1, day) + + console.log(date) + + return date.toISOString() +} + export { entryParser } diff --git a/web/src/plugins/date.js b/web/src/plugins/date.js index 4565e5d..08aee42 100644 --- a/web/src/plugins/date.js +++ b/web/src/plugins/date.js @@ -6,7 +6,7 @@ Vue.filter('dateAndTime', val => format(new Date(val), "d 'de' MMMM 'de' yyyy 'às' HH:MM", { locale }) ) -Vue.filter('shortDate', val => format(val, 'dd/MM/yyyy', { locale })) +Vue.filter('shortDate', val => format(new Date(val), 'dd/MM/yyyy', { locale })) Vue.filter('from', val => formatDistance(new Date(val), Date.now(), { locale, addSuffix: true }) diff --git a/web/src/views/PrintToken.vue b/web/src/views/PrintToken.vue index 27263b9..1f416ee 100755 --- a/web/src/views/PrintToken.vue +++ b/web/src/views/PrintToken.vue @@ -31,10 +31,7 @@
Válido até - {{ - tokenInfo.expiration - | dateAndtime - }} + {{ tokenInfo.expiration | dateAndtime }}