Add block device selector in restore view
This commit is contained in:
@@ -6,7 +6,8 @@ exports = module.exports = {
|
||||
activate,
|
||||
restore,
|
||||
getStatus,
|
||||
setupTokenAuth
|
||||
setupTokenAuth,
|
||||
getBlockDevices
|
||||
};
|
||||
|
||||
const assert = require('assert'),
|
||||
@@ -17,7 +18,9 @@ const assert = require('assert'),
|
||||
paths = require('../paths.js'),
|
||||
provision = require('../provision.js'),
|
||||
safe = require('safetydance'),
|
||||
superagent = require('superagent');
|
||||
superagent = require('superagent'),
|
||||
system = require('../system.js'),
|
||||
users = require('../users.js');
|
||||
|
||||
function setupTokenAuth(req, res, next) {
|
||||
assert.strictEqual(typeof req.body, 'object');
|
||||
@@ -129,3 +132,13 @@ async function getStatus(req, res, next) {
|
||||
|
||||
next(new HttpSuccess(200, status));
|
||||
}
|
||||
|
||||
async function getBlockDevices(req, res, next) {
|
||||
const activated = await users.isActivated();
|
||||
if (activated) throw new BoxError(BoxError.NOT_ALLOWED, 'Only available during restore.');
|
||||
|
||||
const [error, devices] = await safe(system.getBlockDevices());
|
||||
if (error) return next(new HttpError(500, error));
|
||||
|
||||
next(new HttpSuccess(200, { devices }));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user