Added username_to_uuid convenience function to LoginProvider

This commit is contained in:
tylerlowrey 2020-08-11 11:59:27 -04:00 committed by Joshua Yanovski
parent 2b0c1e89f3
commit 2c55afcfa9

View File

@ -1,4 +1,4 @@
use authc::{AuthClient, AuthToken, Uuid};
use authc::{AuthClient, AuthToken, Uuid, AuthClientError};
use common::msg::RegisterError;
use hashbrown::HashMap;
use std::str::FromStr;
@ -103,4 +103,8 @@ impl LoginProvider {
},
}
}
pub fn username_to_uuid(&self, username: &str) -> Result<Uuid, AuthClientError> {
self.auth_server.map_or_else(|| Ok(derive_uuid(username)), |username| auth.username_to_uuid(username))
}
}