Add support for draft/account-registration
A new UI to register and verify accounts is added.
This commit is contained in:
parent
b1d5f1436e
commit
be08302c1f
6 changed files with 278 additions and 13 deletions
|
@ -17,6 +17,7 @@ const permanentCaps = [
|
|||
"server-time",
|
||||
"setname",
|
||||
|
||||
"draft/account-registration",
|
||||
"draft/chathistory",
|
||||
"draft/event-playback",
|
||||
"draft/extended-monitor",
|
||||
|
@ -552,6 +553,14 @@ export default class Client extends EventTarget {
|
|||
return saslCap.split(",").includes(mech);
|
||||
}
|
||||
|
||||
checkAccountRegistrationCap(k) {
|
||||
let v = this.availableCaps["draft/account-registration"];
|
||||
if (v === undefined) {
|
||||
return false;
|
||||
}
|
||||
return v.split(",").includes(k);
|
||||
}
|
||||
|
||||
requestCaps() {
|
||||
let wantCaps = [].concat(permanentCaps);
|
||||
if (!this.params.bouncerNetwork) {
|
||||
|
@ -915,4 +924,45 @@ export default class Client extends EventTarget {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
registerAccount(email, password) {
|
||||
let msg = {
|
||||
command: "REGISTER",
|
||||
params: ["*", email || "*", password],
|
||||
};
|
||||
return this.roundtrip(msg, (msg) => {
|
||||
switch (msg.command) {
|
||||
case "REGISTER":
|
||||
let result = msg.params[0];
|
||||
return {
|
||||
verificationRequired: result === "VERIFICATION_REQUIRED",
|
||||
account: msg.params[1],
|
||||
message: msg.params[2],
|
||||
};
|
||||
case "FAIL":
|
||||
if (msg.params[0] === "REGISTER") {
|
||||
throw msg;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
verifyAccount(account, code) {
|
||||
let msg = {
|
||||
command: "VERIFY",
|
||||
params: [account, code],
|
||||
};
|
||||
return this.roundtrip(msg, (msg) => {
|
||||
switch (msg.command) {
|
||||
case "VERIFY":
|
||||
return { message: msg.params[2] };
|
||||
case "FAIL":
|
||||
if (msg.params[0] === "VERIFY") {
|
||||
throw msg;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue