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,
|
to: None,
|
||||||
r#type: IqType::Result,
|
r#type: IqType::Result,
|
||||||
body: BindResponse(Jid {
|
body: BindResponse(Jid {
|
||||||
name: Some(Name("darova".into())),
|
name: Some(self.user.xmpp_name.clone()),
|
||||||
server: Server("localhost".into()),
|
server: Server("localhost".into()),
|
||||||
resource: Some(Resource("kek".into())),
|
resource: Some(self.user.xmpp_resource.clone()),
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
req.serialize(output);
|
req.serialize(output);
|
||||||
|
|
|
@ -52,9 +52,17 @@ struct LoadedConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Authenticated {
|
struct Authenticated {
|
||||||
|
/// Identifier of the authenticated player.
|
||||||
|
///
|
||||||
|
/// Used when communicating with lavina-core on behalf of the player.
|
||||||
player_id: PlayerId,
|
player_id: PlayerId,
|
||||||
|
/// The user's XMPP name.
|
||||||
|
///
|
||||||
|
/// Used in `to` and `from` fields of XMPP messages.
|
||||||
xmpp_name: Name,
|
xmpp_name: Name,
|
||||||
|
/// The resource given to this user by the server.
|
||||||
xmpp_resource: Resource,
|
xmpp_resource: Resource,
|
||||||
|
/// The resource used by this user when joining MUCs.
|
||||||
xmpp_muc_name: Resource,
|
xmpp_muc_name: Resource,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,11 +315,13 @@ async fn socket_auth(
|
||||||
return Err(fail("passwords do not match"));
|
return Err(fail("passwords do not match"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let name: Str = name.as_str().into();
|
||||||
|
|
||||||
Ok(Authenticated {
|
Ok(Authenticated {
|
||||||
player_id: PlayerId::from(name.as_str())?,
|
player_id: PlayerId::from(name.clone())?,
|
||||||
xmpp_name: Name(name.to_string().into()),
|
xmpp_name: Name(name.clone()),
|
||||||
xmpp_resource: Resource(name.to_string().into()),
|
xmpp_resource: Resource(name.clone()),
|
||||||
xmpp_muc_name: Resource(name.to_string().into()),
|
xmpp_muc_name: Resource(name.clone()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Err(e) => return Err(e),
|
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
|
// 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)]
|
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||||
pub struct Name(pub Str);
|
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)]
|
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||||
pub struct Server(pub Str);
|
pub struct Server(pub Str);
|
||||||
|
|
||||||
|
/// Resource of an XMPP entity. Placed after the `/` in a JID.
|
||||||
#[derive(PartialEq, Eq, Debug, Clone)]
|
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||||
pub struct Resource(pub Str);
|
pub struct Resource(pub Str);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue