forked from lavina/lavina
xmpp: fix handling of the `bind` iq
This commit is contained in:
parent
36b0d50d51
commit
8b099f9be2
|
@ -24,9 +24,9 @@ impl<'a> XmppConnection<'a> {
|
|||
to: None,
|
||||
r#type: IqType::Result,
|
||||
body: BindResponse(Jid {
|
||||
name: Some(Name("darova".into())),
|
||||
name: Some(self.user.xmpp_name.clone()),
|
||||
server: Server("localhost".into()),
|
||||
resource: Some(Resource("kek".into())),
|
||||
resource: Some(self.user.xmpp_resource.clone()),
|
||||
}),
|
||||
};
|
||||
req.serialize(output);
|
||||
|
|
|
@ -52,9 +52,17 @@ struct LoadedConfig {
|
|||
}
|
||||
|
||||
struct Authenticated {
|
||||
/// Identifier of the authenticated player.
|
||||
///
|
||||
/// Used when communicating with lavina-core on behalf of the player.
|
||||
player_id: PlayerId,
|
||||
/// The user's XMPP name.
|
||||
///
|
||||
/// Used in `to` and `from` fields of XMPP messages.
|
||||
xmpp_name: Name,
|
||||
/// The resource given to this user by the server.
|
||||
xmpp_resource: Resource,
|
||||
/// The resource used by this user when joining MUCs.
|
||||
xmpp_muc_name: Resource,
|
||||
}
|
||||
|
||||
|
@ -307,11 +315,13 @@ async fn socket_auth(
|
|||
return Err(fail("passwords do not match"));
|
||||
}
|
||||
|
||||
let name: Str = name.as_str().into();
|
||||
|
||||
Ok(Authenticated {
|
||||
player_id: PlayerId::from(name.as_str())?,
|
||||
xmpp_name: Name(name.to_string().into()),
|
||||
xmpp_resource: Resource(name.to_string().into()),
|
||||
xmpp_muc_name: Resource(name.to_string().into()),
|
||||
player_id: PlayerId::from(name.clone())?,
|
||||
xmpp_name: Name(name.clone()),
|
||||
xmpp_resource: Resource(name.clone()),
|
||||
xmpp_muc_name: Resource(name.clone()),
|
||||
})
|
||||
}
|
||||
Err(e) => return Err(e),
|
||||
|
|
|
@ -11,12 +11,15 @@ pub const XMLNS: &'static str = "urn:ietf:params:xml:ns:xmpp-bind";
|
|||
|
||||
// TODO remove `pub` in newtypes, introduce validation
|
||||
|
||||
/// Name (node identifier) of an XMPP entity. Placed before the `@` in a JID.
|
||||
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||
pub struct Name(pub Str);
|
||||
|
||||
/// Server name of an XMPP entity. Placed after the `@` and before the `/` in a JID.
|
||||
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||
pub struct Server(pub Str);
|
||||
|
||||
/// Resource of an XMPP entity. Placed after the `/` in a JID.
|
||||
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||
pub struct Resource(pub Str);
|
||||
|
||||
|
|
Loading…
Reference in New Issue