diff --git a/docs/todo.md b/docs/todo.md index 9703d02..634bf8e 100644 --- a/docs/todo.md +++ b/docs/todo.md @@ -23,13 +23,13 @@ - [ ] 5.3.4.7 Dummy Auth - [ ] 5.3.5 Fallback - [ ] 5.3.5.1 Example - - [ ] 5.3.6 Identifier types - - [ ] 5.3.6.1 Matrix User ID - - [ ] 5.3.6.2 Third-party ID - - [ ] 5.3.6.3 Phone number + - [x] ~~5.3.6 Identifier types~~ + - [x] ~~5.3.6.1 Matrix User ID~~ + - [x] ~~5.3.6.2 Third-party ID~~ + - [x] ~~5.3.6.3 Phone number~~ - [ ] 5.4 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.4 POST /_matrix/client/r0/logout/all - [ ] 5.4.5 Login Fallback diff --git a/src/api/client.rs b/src/api/client.rs index 96af400..c64ace5 100644 --- a/src/api/client.rs +++ b/src/api/client.rs @@ -303,6 +303,8 @@ impl Client { // Holds implementation for Section 5.4, Login 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). + /// + /// This request is rate-limited but does not require authentication. pub fn login_flows(&self) -> Result> { Ok(self .send( @@ -326,6 +328,8 @@ impl Client { /// /// You may specify a device display name if the provided device ID is not /// known. It is ignored if the device ID already exists. + /// + /// This request is rate-limited but does not require authentication. pub fn login_password( &self, identifier: IdentifierType, @@ -355,6 +359,8 @@ impl Client { /// /// You may specify a device display name if the provided device ID is not /// known. It is ignored if the device ID already exists. + /// + /// This request is rate-limited but does not require authentication. pub fn login_token( &self, 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( &self, body: Value, diff --git a/src/api/methods/login.rs b/src/api/methods/login.rs index fed85fd..ac0961e 100644 --- a/src/api/methods/login.rs +++ b/src/api/methods/login.rs @@ -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) /// for more details. #[derive(Deserialize, Serialize)] +#[serde(tag = "type")] pub enum IdentifierType { #[serde(rename = "m.id.user")] - User, + User { user: String }, #[serde(rename = "m.id.thirdparty")] - ThirdParty, + ThirdParty { medium: String, address: String }, #[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 #[derive(Deserialize)] pub struct LoginResponse {