mirror of
https://github.com/element-hq/element-web
synced 2024-11-28 12:28:50 +03:00
Fix vector-im/riot-web#2833 : Fail nicely when people try to register numeric user IDs
This commit is contained in:
parent
1d5112db5d
commit
f168f9cd06
1 changed files with 13 additions and 1 deletions
|
@ -203,7 +203,19 @@ class Register extends Signup {
|
|||
} else if (error.errcode == 'M_INVALID_USERNAME') {
|
||||
throw new Error("User names may only contain alphanumeric characters, underscores or dots!");
|
||||
} else if (error.httpStatus >= 400 && error.httpStatus < 500) {
|
||||
throw new Error(`Registration failed! (${error.httpStatus})`);
|
||||
let msg = null;
|
||||
if (error.message) {
|
||||
msg = error.message;
|
||||
}
|
||||
else if (error.errcode) {
|
||||
msg = error.errcode;
|
||||
}
|
||||
if (msg) {
|
||||
throw new Error(`Registration failed! (${error.httpStatus}) - ${msg}`);
|
||||
}
|
||||
else {
|
||||
throw new Error(`Registration failed! (${error.httpStatus}) - That's all we know.`);
|
||||
}
|
||||
} else if (error.httpStatus >= 500 && error.httpStatus < 600) {
|
||||
throw new Error(
|
||||
`Server error during registration! (${error.httpStatus})`
|
||||
|
|
Loading…
Reference in a new issue