appstore: add unlink account route
This commit is contained in:
@@ -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, {}));
|
||||
|
||||
Reference in New Issue
Block a user