[impl] Add temporary service screen to generate command to create new license

This commit is contained in:
Peter Sykora 2018-10-13 22:56:07 +02:00
parent bbec2a1602
commit 7e4fe40a5f
3 changed files with 21 additions and 0 deletions

5
package-lock.json generated
View File

@ -3641,6 +3641,11 @@
"platform": "1.3.5"
}
},
"hi-base32": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/hi-base32/-/hi-base32-0.5.0.tgz",
"integrity": "sha512-DDRmxSyoYuvjUb9EnXdoiMChBZ7ZcUVJsK5Frd3kqMhuBxvmZdnBeynAVfj7/ECbn++CekcoprvC/rprHPAtow=="
},
"hide-powered-by": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/hide-powered-by/-/hide-powered-by-1.0.0.tgz",

View File

@ -24,6 +24,7 @@
"date-fns": "^1.29.0",
"dotenv": "^5.0.1",
"es6-denodeify": "^0.1.5",
"hi-base32": "^0.5.0",
"http-shutdown": "^1.2.0",
"humps": "^2.0.1",
"join-js": "^1.0.0",

View File

@ -15,4 +15,19 @@ backend.use(login)
router.use('/api', api.routes())
router.use('/backend', backend.routes())
const base32 = require('hi-base32')
const crypto = require('crypto')
router.get('/temp/generate-new-license', async function(ctx) {
const licenseNum = base32.encode(crypto.randomBytes(15))
const licenseNumNice = licenseNum.match(/.{4}/g).join('-')
ctx.body = '<html><body>' +
`License for client: <pre>${licenseNumNice}</pre>` +
'SQL command to insert license into database with 2 licensed modules <strong>ccengine</strong> (windows app) and <strong>cndata</strong> (CN data): <pre>' +
`Insert Into License (productId, licenseNum, customerId) Values ('coc', '${licenseNum}', '123456');\n` +
`Insert Into LicensedModule (productId, licenseNum, moduleId) Values ('coc', '${licenseNum}', 'ccengine');\n` +
`Insert Into LicensedModule (productId, licenseNum, moduleId) Values ('coc', '${licenseNum}', 'cndata');\n` +
'</pre>' +
'</body></html>'
});
module.exports = router