appstore: add unlink account route
This commit is contained in:
@@ -17,6 +17,7 @@ exports = module.exports = {
|
||||
|
||||
registerCloudron3,
|
||||
updateCloudron,
|
||||
unlinkAccount,
|
||||
|
||||
getSubscription,
|
||||
isFreePlan,
|
||||
@@ -32,6 +33,7 @@ exports = module.exports = {
|
||||
const assert = require('node:assert'),
|
||||
BoxError = require('./boxerror.js'),
|
||||
constants = require('./constants.js'),
|
||||
dashboard = require('./dashboard.js'),
|
||||
debug = require('debug')('box:appstore'),
|
||||
manifestFormat = require('@cloudron/manifest-format'),
|
||||
paths = require('./paths.js'),
|
||||
@@ -223,9 +225,9 @@ async function getAppUpdate(app, options) {
|
||||
return updateInfo;
|
||||
}
|
||||
|
||||
async function registerCloudron3(domain, version) {
|
||||
assert.strictEqual(typeof domain, 'string');
|
||||
assert.strictEqual(typeof version, 'string');
|
||||
async function registerCloudron3() {
|
||||
const { domain } = await dashboard.getLocation();
|
||||
const version = constants.VERSION;
|
||||
|
||||
const token = await settings.get(settings.APPSTORE_API_TOKEN_KEY);
|
||||
if (token) { // when installed using setupToken, this updates the domain record when called during provisioning
|
||||
@@ -250,6 +252,13 @@ async function registerCloudron3(domain, version) {
|
||||
debug(`registerCloudron3: Cloudron registered with id ${response.body.cloudronId}`);
|
||||
}
|
||||
|
||||
async function unlinkAccount() {
|
||||
debug('unlinkAccount: Unlinking existing account.');
|
||||
|
||||
await unregister();
|
||||
return await registerCloudron3();
|
||||
}
|
||||
|
||||
async function updateCloudron(data) {
|
||||
assert.strictEqual(typeof data, 'object');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user