client-api: Add registration token validity checking endpoint

This commit is contained in:
Callum Brown 2021-11-09 12:30:30 +00:00 committed by GitHub
parent a9ecd7f397
commit 975efcd2ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 0 deletions

View File

@ -3,6 +3,8 @@
pub mod add_3pid; pub mod add_3pid;
pub mod bind_3pid; pub mod bind_3pid;
pub mod change_password; pub mod change_password;
#[cfg(feature = "unstable-pre-spec")]
pub mod check_registration_token_validity;
pub mod deactivate; pub mod deactivate;
pub mod delete_3pid; pub mod delete_3pid;
pub mod get_3pids; pub mod get_3pids;

View File

@ -0,0 +1,41 @@
//! [GET /_matrix/client/unstable/org.matrix.msc3231/register/org.matrix.msc3231.login.registration_token/validity](https://github.com/matrix-org/matrix-doc/blob/main/proposals/3231-token-authenticated-registration.md#checking-the-validity-of-a-token)
use ruma_api::ruma_api;
ruma_api! {
metadata: {
description: "Checks to see if the given registration token is valid.",
method: GET,
name: "check_registration_token_validity",
path: "/_matrix/client/unstable/org.matrix.msc3231/register/org.matrix.msc3231.login.registration_token/validity",
rate_limited: true,
authentication: None,
}
request: {
/// The registration token to check the validity of.
#[ruma_api(query)]
pub registration_token: &'a str,
}
response: {
/// A flag to indicate that the registration token is valid.
pub valid: bool,
}
error: crate::Error
}
impl<'a> Request<'a> {
/// Creates a new `Request` with the given registration token.
pub fn new(registration_token: &'a str) -> Self {
Self { registration_token }
}
}
impl Response {
/// Creates a new `Response` with the given validity flag.
pub fn new(valid: bool) -> Self {
Self { valid }
}
}