From 252cd3b781c66a3dbda202474a530aa64425f186 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 16 Jun 2021 09:03:34 +0200 Subject: [PATCH] implement new helper is_active_user_id() --- src/config/cached_user_info.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/config/cached_user_info.rs b/src/config/cached_user_info.rs index c85d643c..a574043f 100644 --- a/src/config/cached_user_info.rs +++ b/src/config/cached_user_info.rs @@ -65,10 +65,8 @@ impl CachedUserInfo { } } - /// Test if a authentication id is enabled and not expired - pub fn is_active_auth_id(&self, auth_id: &Authid) -> bool { - let userid = auth_id.user(); - + /// Test if a user_id is enabled and not expired + pub fn is_active_user_id(&self, userid: &Userid) -> bool { if let Ok(info) = self.user_cfg.lookup::("user", userid.as_str()) { if !info.enable.unwrap_or(true) { return false; @@ -78,7 +76,17 @@ impl CachedUserInfo { return false; } } + true } else { + false + } + } + + /// Test if a authentication id is enabled and not expired + pub fn is_active_auth_id(&self, auth_id: &Authid) -> bool { + let userid = auth_id.user(); + + if !self.is_active_user_id(userid) { return false; }