diff --git a/app/src/api/errors.js b/app/src/api/errors.js
index cbca7c12..f120ac02 100644
--- a/app/src/api/errors.js
+++ b/app/src/api/errors.js
@@ -47,6 +47,7 @@ class APIBadRequestError extends APIError {
constructor (method, response, errorData) {
super(method, response, errorData)
this.name = 'APIBadRequestError'
+ this.key = errorData.error_key
}
}
diff --git a/app/src/components/globals/CardForm.vue b/app/src/components/globals/CardForm.vue
index 1867f4bd..8debb8a3 100644
--- a/app/src/components/globals/CardForm.vue
+++ b/app/src/components/globals/CardForm.vue
@@ -10,7 +10,10 @@
@@ -71,14 +91,20 @@ export default { return { step: 'start', domain: undefined, - password: undefined + password: undefined, + serverError: '' } }, methods: { + goToStep (step) { + this.serverError = '' + this.step = step + }, + setDomain ({ domain }) { this.domain = domain - this.step = 'password' + this.goToStep('password') }, async setPassword ({ password }) { @@ -90,11 +116,23 @@ export default { this.performPostInstall() }, - performPostInstall () { + performPostInstall (force = false) { // FIXME does the api will throw an error for bad passwords ? - api.post('postinstall', { domain: this.domain, password: this.password }).then(data => { + api.post('postinstall' + (force ? '?force_diskspace' : ''), { domain: this.domain, password: this.password }).then(data => { // Display success message and allow the user to login - this.step = 'login' + this.goToStep('login') + }).catch(err => { + if (err.name !== 'APIBadRequestError') throw err + if (err.key === 'postinstall_low_rootfsspace') { + this.step = 'rootfsspace-error' + } else if (err.key.includes('password')) { + this.step = 'password' + } else if (['domain', 'dyndns'].some(word => err.key.includes(word))) { + this.step = 'domain' + } else { + throw err + } + this.serverError = err.message }) } },