aboutsummaryrefslogtreecommitdiff
path: root/src/services/errors/errors.js
diff options
context:
space:
mode:
authorShpuld Shpludson <shp@cock.li>2020-01-14 13:45:00 +0000
committerShpuld Shpludson <shp@cock.li>2020-01-14 13:45:00 +0000
commit662afe973a72efc17e61fd4c071ed985bfe4bf6b (patch)
treebbaab78908dd331640c372e1fad7cfb6e5c5e734 /src/services/errors/errors.js
parentac90d4c5329c513d73871b3a2476761672453775 (diff)
Fix #750 , fix error messages and captcha resetting
Diffstat (limited to 'src/services/errors/errors.js')
-rw-r--r--src/services/errors/errors.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/services/errors/errors.js b/src/services/errors/errors.js
index 590552da..d4cf9132 100644
--- a/src/services/errors/errors.js
+++ b/src/services/errors/errors.js
@@ -32,12 +32,18 @@ export class RegistrationError extends Error {
}
if (typeof error === 'object') {
+ const errorContents = JSON.parse(error.error)
+ // keys will have the property that has the error, for example 'ap_id',
+ // 'email' or 'captcha', the value will be an array of its error
+ // like "ap_id": ["has been taken"] or "captcha": ["Invalid CAPTCHA"]
+
// replace ap_id with username
- if (error.ap_id) {
- error.username = error.ap_id
- delete error.ap_id
+ if (errorContents.ap_id) {
+ errorContents.username = errorContents.ap_id
+ delete errorContents.ap_id
}
- this.message = humanizeErrors(error)
+
+ this.message = humanizeErrors(errorContents)
} else {
this.message = error
}