From 2c55afcfa911268733a805f7ebfca82a687001a1 Mon Sep 17 00:00:00 2001 From: tylerlowrey Date: Tue, 11 Aug 2020 11:59:27 -0400 Subject: [PATCH] Added username_to_uuid convenience function to LoginProvider --- server/src/login_provider.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/src/login_provider.rs b/server/src/login_provider.rs index f5236e1fc3..3111f6fa47 100644 --- a/server/src/login_provider.rs +++ b/server/src/login_provider.rs @@ -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 { + self.auth_server.map_or_else(|| Ok(derive_uuid(username)), |username| auth.username_to_uuid(username)) + } }