File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -149,12 +149,18 @@ pub async fn user_auth_for_datasets(
149149pub fn is_admin ( req : & HttpRequest ) -> Result < bool , anyhow:: Error > {
150150 let session_key =
151151 extract_session_key_from_req ( req) . map_err ( |e| anyhow:: Error :: msg ( e. to_string ( ) ) ) ?;
152- let userid = if let Some ( u) = Users . get_userid_from_session ( & session_key) {
153- u
154- } else {
155- return Err ( anyhow:: Error :: msg ( "User not found" ) ) ;
156- } ;
157- let permissions = Users . get_role ( & userid) ;
158152
159- Ok ( permissions. contains ( & String :: from ( "admin" ) ) )
153+ let permissions = Users . get_permissions ( & session_key) ;
154+
155+ // Check if user has admin permissions (Action::All on All resources)
156+ for permission in permissions. iter ( ) {
157+ match permission {
158+ Permission :: Resource ( Action :: All , ParseableResourceType :: All ) => {
159+ return Ok ( true ) ;
160+ }
161+ _ => continue ,
162+ }
163+ }
164+
165+ Ok ( false )
160166}
You can’t perform that action at this time.
0 commit comments