appstore: add unlink account route

This commit is contained in:
Girish Ramakrishnan
2025-09-24 21:25:31 +02:00
parent a38ef2b6f5
commit 98d4d99c1b
11 changed files with 37 additions and 54 deletions

View File

@@ -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');