cleaned up channel binding logic, cleaned up SaslCredentials, updated documentation

This commit is contained in:
lumi 2017-03-07 15:02:38 +01:00
commit 88ea00baa7
5 changed files with 92 additions and 56 deletions

View file

@ -30,7 +30,11 @@ impl SaslMechanism for Plain {
fn from_credentials(credentials: SaslCredentials) -> Result<Plain, String> {
if let SaslSecret::Password(password) = credentials.secret {
Ok(Plain::new(credentials.username, password))
if let Some(username) = credentials.username {
Ok(Plain::new(username, password))
} else {
Err("PLAIN requires a username".to_owned())
}
} else {
Err("PLAIN requires a password".to_owned())
}