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:
+1
-1
@@ -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
@@ -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
@@ -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
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user