matrix-org / matrix-ircd

An IRCd implementation backed by Matrix.
Apache License 2.0
224 stars 41 forks source link

client/r0/login lacks required field "identifier" #68

Open spaetz opened 4 years ago

spaetz commented 4 years ago

Hi, just trying out matrix-ircd, thanks! Using it with the conduit.rs matrix server, I get error messages when trying to connect and login. The server returns Error: "missing field identifier method: POST, uri: /_matrix/client/r0/login and indeed that field does not seem to be sent, despite being one of the required fields in the spec:

https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-login

Could that be implemented, pretty please? :-) Update: identifier has superceeded the "user" field and should be used instead of the user field. I don't know enough rust to provide a patch to send a "User identifier" but that is what should be send nowadays.

iinuwa commented 4 years ago

Here is the relevant code, I think. I think adding a couple of types could fix this (quick prototype, not buildable syntax...):

#[derive(Debug, Clone, Serialize)]
#[serde(untagged)]
pub enum UserIdentifierType {
    #[serde(rename = "m.id.user")]
    User,
    #[serde(rename = "m.id.thirdparty")]
    ThirdParty,
    #[serde(rename = "m.id.phone")]
    Phone,
}

#[derive(Debug, Clone, Serialize)]
#[serde(untagged)]
pub enum UserIdentifier {
    User {
        #[serde(rename = "type")]
        identifier_type: UserIdentifierType::User,
        user: String,
    },
   ThirdParty {
        #[serde(rename = "type")]
        identifier_type: UserIdentifierType::ThirdParty,
        medium: String,
        address: String,
    },
    Phone {
        #[serde(rename = "type")]
        identifier_type: UserIdentifierType::User,
        country: String,
        phone: String,
    },
}

And adding a identifier: UserIdentifier field to LoginPasswordInput could work.

Cf.