properly implemented identifier types

This commit is contained in:
Edward Shen 2019-08-21 20:54:43 -04:00
parent 84305ad96e
commit a98c9279d4
Signed by: edward
GPG key ID: F350507060ED6C90
3 changed files with 18 additions and 9 deletions

View file

@ -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

View file

@ -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<ValidLoginFlows, Box<dyn Error>> {
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,

View file

@ -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 {