Add appstore web token
* For existing installs, migrate using the soon to be obsoleted user_token route * For new installs, the token post login is stashed during registration time
This commit is contained in:
@@ -49,6 +49,9 @@ exports = module.exports = {
|
||||
getAppstoreApiToken,
|
||||
setAppstoreApiToken,
|
||||
|
||||
getAppstoreWebToken,
|
||||
setAppstoreWebToken,
|
||||
|
||||
getSysinfoConfig,
|
||||
setSysinfoConfig,
|
||||
|
||||
@@ -113,6 +116,7 @@ exports = module.exports = {
|
||||
LANGUAGE_KEY: 'language',
|
||||
CLOUDRON_ID_KEY: 'cloudron_id',
|
||||
APPSTORE_API_TOKEN_KEY: 'appstore_api_token',
|
||||
APPSTORE_WEB_TOKEN_KEY: 'appstore_web_token',
|
||||
FIREWALL_BLOCKLIST_KEY: 'firewall_blocklist',
|
||||
|
||||
API_SERVER_ORIGIN_KEY: 'api_server_origin',
|
||||
@@ -171,6 +175,7 @@ const gDefaults = (function () {
|
||||
result[exports.LANGUAGE_KEY] = 'en';
|
||||
result[exports.CLOUDRON_ID_KEY] = '';
|
||||
result[exports.APPSTORE_API_TOKEN_KEY] = '';
|
||||
result[exports.APPSTORE_WEB_TOKEN_KEY] = '';
|
||||
result[exports.BACKUP_CONFIG_KEY] = {
|
||||
provider: 'filesystem',
|
||||
backupFolder: '/var/backups',
|
||||
@@ -708,6 +713,19 @@ async function setAppstoreApiToken(token) {
|
||||
notifyChange(exports.APPSTORE_API_TOKEN_KEY, token);
|
||||
}
|
||||
|
||||
async function getAppstoreWebToken() {
|
||||
const value = await get(exports.APPSTORE_WEB_TOKEN_KEY);
|
||||
if (value === null) return gDefaults[exports.APPSTORE_WEB_TOKEN_KEY];
|
||||
return value;
|
||||
}
|
||||
|
||||
async function setAppstoreWebToken(token) {
|
||||
assert.strictEqual(typeof token, 'string');
|
||||
|
||||
await set(exports.APPSTORE_WEB_TOKEN_KEY, token);
|
||||
notifyChange(exports.APPSTORE_WEB_TOKEN_KEY, token);
|
||||
}
|
||||
|
||||
async function list() {
|
||||
const settings = await database.query(`SELECT ${SETTINGS_FIELDS} FROM settings WHERE value IS NOT NULL ORDER BY name`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user