Website: Update license key generator action and helper inputs (#9265)

Changes:
- Updated the `expiresAt` input description in
`api/controllers/admin/generate-license-key.js` and
`api/helpers/create-license-key.js`
- Updated timestamps sent to `generate-license-key` and
`create-license-key` to be in seconds.

 . .

Co-authored-by: Mike McNeil <mikermcneil@users.noreply.github.com>
This commit is contained in:
Eric
2023-01-11 11:11:43 -06:00
committed by GitHub
co-authored by Mike McNeil
parent 3072f34c1b
commit 112dffbd1e
3 changed files with 10 additions and 8 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ module.exports = {
expiresAt: {
type: 'number',
required: true,
description: 'A JS timestamp representing when this license will expire.'
description: 'A JS timestamp representing when this license will expire.',
}
},
+6 -5
View File
@@ -22,7 +22,7 @@ module.exports = {
expiresAt: {
type: 'number',
required: true,
description: 'A JS Timestamp representing when this license will expire.'
description: 'A JS timestamp representing when this license will expire.'
}
},
@@ -37,16 +37,17 @@ module.exports = {
},
fn: async function (inputs) {
fn: async function ({numberOfHosts, organization, expiresAt}) {
let jwt = require('jsonwebtoken');
let expirationTimestampInSeconds = (expiresAt / 1000);
let token = jwt.sign(
{
iss: 'Fleet Device Management Inc.',
exp: inputs.expiresAt,
sub: inputs.organization,
devices: inputs.numberOfHosts,
exp: expirationTimestampInSeconds,
sub: organization,
devices: numberOfHosts,
note: 'Created with Fleet License key dispenser',
tier: 'premium',
},
+3 -2
View File
@@ -41,11 +41,12 @@ parasails.registerPage('generate-license', {
methods: {
handleSubmittingForm: async function() {
let validToDate = new Date(this.formData.expiresAt);
let validToTimestamp = validToDate.getTime();
let licenseExpiresAt = validToDate.getTime();
this.generatedLicenseKey = await Cloud.generateLicenseKey.with({
numberOfHosts: this.formData.numberOfHosts,
organization: this.formData.organization,
expiresAt: validToTimestamp
expiresAt: licenseExpiresAt
});
},