properly implemented identifier types
This commit is contained in:
parent
84305ad96e
commit
a98c9279d4
3 changed files with 18 additions and 9 deletions
10
docs/todo.md
10
docs/todo.md
|
@ -23,13 +23,13 @@
|
||||||
- [ ] 5.3.4.7 Dummy Auth
|
- [ ] 5.3.4.7 Dummy Auth
|
||||||
- [ ] 5.3.5 Fallback
|
- [ ] 5.3.5 Fallback
|
||||||
- [ ] 5.3.5.1 Example
|
- [ ] 5.3.5.1 Example
|
||||||
- [ ] 5.3.6 Identifier types
|
- [x] ~~5.3.6 Identifier types~~
|
||||||
- [ ] 5.3.6.1 Matrix User ID
|
- [x] ~~5.3.6.1 Matrix User ID~~
|
||||||
- [ ] 5.3.6.2 Third-party ID
|
- [x] ~~5.3.6.2 Third-party ID~~
|
||||||
- [ ] 5.3.6.3 Phone number
|
- [x] ~~5.3.6.3 Phone number~~
|
||||||
- [ ] 5.4 Login
|
- [ ] 5.4 Login
|
||||||
- [x] 5.4.1 ~~GET /_matrix/client/r0/login~~
|
- [x] 5.4.1 ~~GET /_matrix/client/r0/login~~
|
||||||
- [ ] 5.4.2 POST /_matrix/client/r0/login
|
- [x] 5.4.2 ~~POST /_matrix/client/r0/login~~
|
||||||
- [ ] 5.4.3 POST /_matrix/client/r0/logout
|
- [ ] 5.4.3 POST /_matrix/client/r0/logout
|
||||||
- [ ] 5.4.4 POST /_matrix/client/r0/logout/all
|
- [ ] 5.4.4 POST /_matrix/client/r0/logout/all
|
||||||
- [ ] 5.4.5 Login Fallback
|
- [ ] 5.4.5 Login Fallback
|
||||||
|
|
|
@ -303,6 +303,8 @@ impl Client {
|
||||||
// Holds implementation for Section 5.4, Login
|
// Holds implementation for Section 5.4, Login
|
||||||
impl Client {
|
impl Client {
|
||||||
/// Implementation of [Section 5.4.1 **GET** `/_matrix/client/r0/login`](https://matrix.org/docs/spec/client_server/r0.5.0#get-matrix-client-r0-login).
|
/// Implementation of [Section 5.4.1 **GET** `/_matrix/client/r0/login`](https://matrix.org/docs/spec/client_server/r0.5.0#get-matrix-client-r0-login).
|
||||||
|
///
|
||||||
|
/// This request is rate-limited but does not require authentication.
|
||||||
pub fn login_flows(&self) -> Result<ValidLoginFlows, Box<dyn Error>> {
|
pub fn login_flows(&self) -> Result<ValidLoginFlows, Box<dyn Error>> {
|
||||||
Ok(self
|
Ok(self
|
||||||
.send(
|
.send(
|
||||||
|
@ -326,6 +328,8 @@ impl Client {
|
||||||
///
|
///
|
||||||
/// You may specify a device display name if the provided device ID is not
|
/// You may specify a device display name if the provided device ID is not
|
||||||
/// known. It is ignored if the device ID already exists.
|
/// known. It is ignored if the device ID already exists.
|
||||||
|
///
|
||||||
|
/// This request is rate-limited but does not require authentication.
|
||||||
pub fn login_password(
|
pub fn login_password(
|
||||||
&self,
|
&self,
|
||||||
identifier: IdentifierType,
|
identifier: IdentifierType,
|
||||||
|
@ -355,6 +359,8 @@ impl Client {
|
||||||
///
|
///
|
||||||
/// You may specify a device display name if the provided device ID is not
|
/// You may specify a device display name if the provided device ID is not
|
||||||
/// known. It is ignored if the device ID already exists.
|
/// known. It is ignored if the device ID already exists.
|
||||||
|
///
|
||||||
|
/// This request is rate-limited but does not require authentication.
|
||||||
pub fn login_token(
|
pub fn login_token(
|
||||||
&self,
|
&self,
|
||||||
identifier: IdentifierType,
|
identifier: IdentifierType,
|
||||||
|
@ -373,6 +379,9 @@ impl Client {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Actual method that performs the login request. Accepts a body that
|
||||||
|
/// should already be populated with the login-specific values needed for
|
||||||
|
/// that particular login type.
|
||||||
fn login(
|
fn login(
|
||||||
&self,
|
&self,
|
||||||
body: Value,
|
body: Value,
|
||||||
|
|
|
@ -17,16 +17,16 @@ pub struct LoginFlow {
|
||||||
/// Known identifier types for authentication methods. See [Section 5.3.6](https://matrix.org/docs/spec/client_server/r0.5.0#identifier-types)
|
/// Known identifier types for authentication methods. See [Section 5.3.6](https://matrix.org/docs/spec/client_server/r0.5.0#identifier-types)
|
||||||
/// for more details.
|
/// for more details.
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
|
#[serde(tag = "type")]
|
||||||
pub enum IdentifierType {
|
pub enum IdentifierType {
|
||||||
#[serde(rename = "m.id.user")]
|
#[serde(rename = "m.id.user")]
|
||||||
User,
|
User { user: String },
|
||||||
#[serde(rename = "m.id.thirdparty")]
|
#[serde(rename = "m.id.thirdparty")]
|
||||||
ThirdParty,
|
ThirdParty { medium: String, address: String },
|
||||||
#[serde(rename = "m.id.phone")]
|
#[serde(rename = "m.id.phone")]
|
||||||
Phone
|
Phone { country: String, phone: String },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Response for a valid login from 5.4.2: POST /_matrix/client/r0/login
|
/// Response for a valid login from 5.4.2: POST /_matrix/client/r0/login
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct LoginResponse {
|
pub struct LoginResponse {
|
||||||
|
|
Loading…
Reference in a new issue