diff --git a/dashboard/src/components/CloudronAccount.vue b/dashboard/src/components/CloudronAccount.vue
index 327efcce9..eecd354a3 100644
--- a/dashboard/src/components/CloudronAccount.vue
+++ b/dashboard/src/components/CloudronAccount.vue
@@ -42,6 +42,17 @@ async function refresh() {
status.value = result.status;
}
+async function onResetCloudron() {
+ busy.value = true;
+
+ const [error] = await appstoreModel.resetCloudronId();
+ if (error) return console.error(error);
+
+ await refresh();
+
+ busy.value = false;
+}
+
onMounted(async () => {
const [error, result] = await dashboardModel.config();
if (error) return console.error(error);
@@ -89,16 +100,23 @@ onMounted(async () => {
-
-
-
- {{ $t('settings.appstoreAccount.description') }}
-
-
-
-
-
-
+
+
+ {{ $t('settings.appstoreAccount.description') }}
+
+
+
+
+
+
+
+
+ Unknown Cloudron ID or invalid cloudron.io token.
+
+
+
+
+
diff --git a/dashboard/src/models/AppstoreModel.js b/dashboard/src/models/AppstoreModel.js
index 93a131847..0029c82ee 100644
--- a/dashboard/src/models/AppstoreModel.js
+++ b/dashboard/src/models/AppstoreModel.js
@@ -53,6 +53,17 @@ function create() {
if (result.status !== 201) return [result];
return [null];
},
+ async resetCloudronId() {
+ let result;
+ try {
+ result = await fetcher.post(`${API_ORIGIN}/api/v1/appstore/reset_cloudron`, {}, { access_token: accessToken });
+ } catch (e) {
+ return [e];
+ }
+
+ if (result.status !== 202) return [result];
+ return [null];
+ },
};
}
diff --git a/src/routes/appstore.js b/src/routes/appstore.js
index 13d5b59d8..c1ee59319 100644
--- a/src/routes/appstore.js
+++ b/src/routes/appstore.js
@@ -5,6 +5,7 @@ exports = module.exports = {
getApp,
getAppVersion,
+ resetCloudron,
registerCloudronWithSetupToken,
registerCloudronWithLogin,
getSubscription
@@ -13,6 +14,7 @@ exports = module.exports = {
const appstore = require('../appstore.js'),
assert = require('assert'),
BoxError = require('../boxerror.js'),
+ dashboard = require('../dashboard.js'),
HttpError = require('connect-lastmile').HttpError,
HttpSuccess = require('connect-lastmile').HttpSuccess,
safe = require('safetydance'),
@@ -45,6 +47,21 @@ async function getAppVersion(req, res, next) {
next(new HttpSuccess(200, manifest));
}
+async function resetCloudron(req, res, next) {
+ assert.strictEqual(typeof req.body, 'object');
+
+ let [error, result] = await safe(dashboard.getConfig());
+ if (error) return next(new HttpError(500, 'internal error'));
+
+ const version = result.version;
+ const domain = result.adminDomain;
+
+ [error, result] = await safe(appstore.registerCloudron3(domain, version));
+ if (error) return next(new HttpError(409, 'appstore not reachable'));
+
+ next(new HttpSuccess(202, {}));
+}
+
async function registerCloudronWithSetupToken(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
diff --git a/src/server.js b/src/server.js
index 0e38e4126..310a03725 100644
--- a/src/server.js
+++ b/src/server.js
@@ -235,6 +235,7 @@ async function initializeExpressSync() {
router.post('/api/v1/directory_server/config', json, token, authorizeAdmin, routes.directoryServer.setConfig);
// appstore and subscription routes
+ router.post('/api/v1/appstore/reset_cloudron', json, token, authorizeOwner, routes.appstore.resetCloudron);
router.post('/api/v1/appstore/register_cloudron', json, token, authorizeOwner, routes.appstore.registerCloudronWithLogin);
router.post('/api/v1/appstore/register_cloudron_with_setup_token', json, token, authorizeOwner, routes.appstore.registerCloudronWithSetupToken);
router.get ('/api/v1/appstore/subscription', token, authorizeUser, routes.appstore.getSubscription); // for all users