From 8721a4435406e6e530792ccce3bf9bc496d23b0e Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 18 Apr 2024 03:06:40 +0200 Subject: [PATCH] feat: helper methods to handle auth cases --- src/server/auth.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/server/auth.rs b/src/server/auth.rs index 13528b1f..afbfe465 100644 --- a/src/server/auth.rs +++ b/src/server/auth.rs @@ -25,6 +25,27 @@ impl Identity { // TODO should we allow all users on same server to see? or just specific user?? } } + + pub fn is_anon(&self) -> bool { + match self { + Self::Anonymous => true, + _ => false, + } + } + + pub fn is_user(&self, uid: &str) -> bool { + match self { + Self::Local(x) => x == uid, + _ => false, + } + } + + pub fn is_server(&self, uid: &str) -> bool { + match self { + Self::Remote(x) => x == uid, + _ => false, + } + } } pub struct AuthIdentity(pub Identity);