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

@@ -5,15 +5,13 @@ exports = module.exports = {
getApp,
getAppVersion,
resetCloudronId,
unlinkAccount,
getSubscription
};
const appstore = require('../appstore.js'),
assert = require('node:assert'),
BoxError = require('../boxerror.js'),
constants = require('../constants.js'),
dashboard = require('../dashboard.js'),
HttpSuccess = require('@cloudron/connect-lastmile').HttpSuccess,
safe = require('safetydance'),
users = require('../users.js'),
@@ -45,13 +43,10 @@ async function getAppVersion(req, res, next) {
next(new HttpSuccess(200, manifest));
}
async function resetCloudronId(req, res, next) {
async function unlinkAccount(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
const [getLocationError, dashboardLocation] = await safe(dashboard.getLocation()); // authenticated route implies already activated
if (getLocationError) return next(BoxError.toHttpError(getLocationError));
const [registerError] = await safe(appstore.registerCloudron3(dashboardLocation.domain, constants.VERSION));
const [registerError] = await safe(appstore.unlinkAccount());
if (registerError) return next(BoxError.toHttpError(registerError));
next(new HttpSuccess(202, {}));