rename cloudron_token to appstore_api_token
This commit is contained in:
+13
-13
@@ -116,7 +116,7 @@ async function registerUser(email, password) {
|
||||
async function createUserToken() {
|
||||
if (settings.isDemo()) throw new BoxError(BoxError.BAD_FIELD, 'Not allowed in demo mode');
|
||||
|
||||
const token = await settings.getCloudronToken();
|
||||
const token = await settings.getAppstoreApiToken();
|
||||
if (!token) throw new BoxError(BoxError.LICENSE_ERROR, 'Missing token');
|
||||
|
||||
const url = `${settings.apiServerOrigin()}/api/v1/user_token`;
|
||||
@@ -134,7 +134,7 @@ async function createUserToken() {
|
||||
}
|
||||
|
||||
async function getSubscription() {
|
||||
const token = await settings.getCloudronToken();
|
||||
const token = await settings.getAppstoreApiToken();
|
||||
if (!token) throw new BoxError(BoxError.LICENSE_ERROR, 'Missing token');
|
||||
|
||||
const url = settings.apiServerOrigin() + '/api/v1/subscription';
|
||||
@@ -167,7 +167,7 @@ async function purchaseApp(data) {
|
||||
assert(data.appstoreId || data.manifestId);
|
||||
assert.strictEqual(typeof data.appId, 'string');
|
||||
|
||||
const token = await settings.getCloudronToken();
|
||||
const token = await settings.getAppstoreApiToken();
|
||||
if (!token) throw new BoxError(BoxError.LICENSE_ERROR, 'Missing token');
|
||||
|
||||
const url = `${settings.apiServerOrigin()}/api/v1/cloudronapps`;
|
||||
@@ -192,7 +192,7 @@ async function unpurchaseApp(appId, data) {
|
||||
assert.strictEqual(typeof data, 'object'); // { appstoreId, manifestId }
|
||||
assert(data.appstoreId || data.manifestId);
|
||||
|
||||
const token = await settings.getCloudronToken();
|
||||
const token = await settings.getAppstoreApiToken();
|
||||
if (!token) throw new BoxError(BoxError.LICENSE_ERROR, 'Missing token');
|
||||
|
||||
const url = `${settings.apiServerOrigin()}/api/v1/cloudronapps/${appId}`;
|
||||
@@ -222,7 +222,7 @@ async function unpurchaseApp(appId, data) {
|
||||
async function getBoxUpdate(options) {
|
||||
assert.strictEqual(typeof options, 'object');
|
||||
|
||||
const token = await settings.getCloudronToken();
|
||||
const token = await settings.getAppstoreApiToken();
|
||||
if (!token) throw new BoxError(BoxError.LICENSE_ERROR, 'Missing token');
|
||||
|
||||
const url = `${settings.apiServerOrigin()}/api/v1/boxupdate`;
|
||||
@@ -265,7 +265,7 @@ async function getAppUpdate(app, options) {
|
||||
assert.strictEqual(typeof app, 'object');
|
||||
assert.strictEqual(typeof options, 'object');
|
||||
|
||||
const token = await settings.getCloudronToken();
|
||||
const token = await settings.getAppstoreApiToken();
|
||||
if (!token) throw new BoxError(BoxError.LICENSE_ERROR, 'Missing token');
|
||||
|
||||
const url = `${settings.apiServerOrigin()}/api/v1/appupdate`;
|
||||
@@ -323,7 +323,7 @@ async function registerCloudron(data) {
|
||||
if (!response.body.cloudronToken) throw new BoxError(BoxError.EXTERNAL_ERROR, 'Invalid response - no token');
|
||||
|
||||
await settings.setCloudronId(response.body.cloudronId);
|
||||
await settings.setCloudronToken(response.body.cloudronToken);
|
||||
await settings.setAppstoreApiToken(response.body.cloudronToken);
|
||||
|
||||
debug(`registerCloudron: Cloudron registered with id ${response.body.cloudronId}`);
|
||||
}
|
||||
@@ -331,7 +331,7 @@ async function registerCloudron(data) {
|
||||
async function updateCloudron(data) {
|
||||
assert.strictEqual(typeof data, 'object');
|
||||
|
||||
const token = await settings.getCloudronToken();
|
||||
const token = await settings.getAppstoreApiToken();
|
||||
if (!token) throw new BoxError(BoxError.LICENSE_ERROR, 'Missing token');
|
||||
|
||||
const url = `${settings.apiServerOrigin()}/api/v1/update_cloudron`;
|
||||
@@ -356,7 +356,7 @@ async function updateCloudron(data) {
|
||||
async function registerWithLoginCredentials(options) {
|
||||
assert.strictEqual(typeof options, 'object');
|
||||
|
||||
const token = await settings.getCloudronToken();
|
||||
const token = await settings.getAppstoreApiToken();
|
||||
if (token) throw new BoxError(BoxError.CONFLICT, 'Cloudron is already registered');
|
||||
|
||||
if (options.signup) await registerUser(options.email, options.password);
|
||||
@@ -368,7 +368,7 @@ async function registerWithLoginCredentials(options) {
|
||||
async function registerWithSetupToken(setupToken) {
|
||||
assert.strictEqual(typeof setupToken, 'string');
|
||||
|
||||
const token = await settings.getCloudronToken();
|
||||
const token = await settings.getAppstoreApiToken();
|
||||
if (token) throw new BoxError(BoxError.CONFLICT, 'Cloudron is already registered');
|
||||
|
||||
await registerCloudron({ domain: settings.dashboardDomain(), setupToken: setupToken, version: constants.VERSION });
|
||||
@@ -383,7 +383,7 @@ async function createTicket(info, auditSource) {
|
||||
assert.strictEqual(typeof info.description, 'string');
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
|
||||
const token = await settings.getCloudronToken();
|
||||
const token = await settings.getAppstoreApiToken();
|
||||
if (!token) throw new BoxError(BoxError.LICENSE_ERROR, 'Missing token');
|
||||
|
||||
if (info.enableSshSupport) {
|
||||
@@ -424,7 +424,7 @@ async function createTicket(info, auditSource) {
|
||||
}
|
||||
|
||||
async function getApps() {
|
||||
const token = await settings.getCloudronToken();
|
||||
const token = await settings.getAppstoreApiToken();
|
||||
if (!token) throw new BoxError(BoxError.LICENSE_ERROR, 'Missing token');
|
||||
|
||||
const unstable = await settings.getUnstableAppsConfig();
|
||||
@@ -455,7 +455,7 @@ async function getAppVersion(appId, version) {
|
||||
|
||||
if (!isAppAllowed(appId, listingConfig)) throw new BoxError(BoxError.FEATURE_DISABLED);
|
||||
|
||||
const token = await settings.getCloudronToken();
|
||||
const token = await settings.getAppstoreApiToken();
|
||||
if (!token) throw new BoxError(BoxError.LICENSE_ERROR, 'Missing token');
|
||||
|
||||
let url = `${settings.apiServerOrigin()}/api/v1/apps/${appId}`;
|
||||
|
||||
@@ -413,7 +413,7 @@ xdescribe('App API', function () {
|
||||
var fake1 = nock(settings.apiServerOrigin()).get('/api/v1/apps/' + APP_STORE_ID).reply(200, { manifest: APP_MANIFEST });
|
||||
var fake2 = nock(settings.apiServerOrigin()).post(function (uri) { return uri.indexOf('/api/v1/cloudronapps') >= 0; }, (body) => body.appstoreId === APP_STORE_ID && body.manifestId === APP_MANIFEST.id && body.appId).reply(201, { });
|
||||
|
||||
await settings.setCloudronToken(USER_1_APPSTORE_TOKEN);
|
||||
await settings.setAppstoreApiToken(USER_1_APPSTORE_TOKEN);
|
||||
|
||||
const res = await superagent.post(SERVER_URL + '/api/v1/apps/install')
|
||||
.query({ access_token: token })
|
||||
|
||||
@@ -82,7 +82,7 @@ async function setup() {
|
||||
const token = await tokens.add({ identifier: user.id, clientId: 'test-client-id', expires: Date.now() + (60 * 60 * 1000), name: 'fromtest' });
|
||||
user.token = token.accessToken;
|
||||
|
||||
await settings._set(settings.CLOUDRON_TOKEN_KEY, exports.appstoreToken); // appstore token
|
||||
await settings._set(settings.APPSTORE_API_TOKEN_KEY, exports.appstoreToken); // appstore token
|
||||
}
|
||||
|
||||
async function cleanup() {
|
||||
|
||||
+10
-10
@@ -46,8 +46,8 @@ exports = module.exports = {
|
||||
getCloudronId,
|
||||
setCloudronId,
|
||||
|
||||
getCloudronToken,
|
||||
setCloudronToken,
|
||||
getAppstoreApiToken,
|
||||
setAppstoreApiToken,
|
||||
|
||||
getSysinfoConfig,
|
||||
setSysinfoConfig,
|
||||
@@ -112,7 +112,7 @@ exports = module.exports = {
|
||||
CLOUDRON_NAME_KEY: 'cloudron_name',
|
||||
LANGUAGE_KEY: 'language',
|
||||
CLOUDRON_ID_KEY: 'cloudron_id',
|
||||
CLOUDRON_TOKEN_KEY: 'cloudron_token', // apstore token
|
||||
APPSTORE_API_TOKEN_KEY: 'appstore_api_token',
|
||||
FIREWALL_BLOCKLIST_KEY: 'firewall_blocklist',
|
||||
|
||||
API_SERVER_ORIGIN_KEY: 'api_server_origin',
|
||||
@@ -170,7 +170,7 @@ const gDefaults = (function () {
|
||||
result[exports.UNSTABLE_APPS_KEY] = true;
|
||||
result[exports.LANGUAGE_KEY] = 'en';
|
||||
result[exports.CLOUDRON_ID_KEY] = '';
|
||||
result[exports.CLOUDRON_TOKEN_KEY] = '';
|
||||
result[exports.APPSTORE_API_TOKEN_KEY] = '';
|
||||
result[exports.BACKUP_CONFIG_KEY] = {
|
||||
provider: 'filesystem',
|
||||
backupFolder: '/var/backups',
|
||||
@@ -695,17 +695,17 @@ async function setCloudronId(cid) {
|
||||
notifyChange(exports.CLOUDRON_ID_KEY, cid);
|
||||
}
|
||||
|
||||
async function getCloudronToken() {
|
||||
const value = await get(exports.CLOUDRON_TOKEN_KEY);
|
||||
if (value === null) return gDefaults[exports.CLOUDRON_TOKEN_KEY];
|
||||
async function getAppstoreApiToken() {
|
||||
const value = await get(exports.APPSTORE_API_TOKEN_KEY);
|
||||
if (value === null) return gDefaults[exports.APPSTORE_API_TOKEN_KEY];
|
||||
return value;
|
||||
}
|
||||
|
||||
async function setCloudronToken(token) {
|
||||
async function setAppstoreApiToken(token) {
|
||||
assert.strictEqual(typeof token, 'string');
|
||||
|
||||
await set(exports.CLOUDRON_TOKEN_KEY, token);
|
||||
notifyChange(exports.CLOUDRON_TOKEN_KEY, token);
|
||||
await set(exports.APPSTORE_API_TOKEN_KEY, token);
|
||||
notifyChange(exports.APPSTORE_API_TOKEN_KEY, token);
|
||||
}
|
||||
|
||||
async function list() {
|
||||
|
||||
+1
-1
@@ -182,7 +182,7 @@ function setup(done) {
|
||||
admin.id = result;
|
||||
},
|
||||
apps.add.bind(null, app.id, app.appStoreId, app.manifest, app.subdomain, app.domain, app.portBindings, app),
|
||||
settings._set.bind(null, settings.CLOUDRON_TOKEN_KEY, exports.appstoreToken), // appstore token
|
||||
settings._set.bind(null, settings.APPSTORE_API_TOKEN_KEY, exports.appstoreToken), // appstore token
|
||||
async function createUser() {
|
||||
const result = await users.add(user.email, user, auditSource);
|
||||
user.id = result;
|
||||
|
||||
Reference in New Issue
Block a user