Skip to content

Commit 70eedba

Browse files
committed
feat: new function to check if user is admin or not
1 parent 701984b commit 70eedba

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/common/jwt_ops.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,9 @@ pub fn get_roles(token: &str) -> Result<Vec<String>, Box<dyn Error>> {
8585

8686
Ok(hsm_name_available_vec)
8787
}
88+
89+
pub fn is_user_admin(shasta_token: &str) -> Result<bool, Box<dyn Error>> {
90+
let roles = get_roles(shasta_token)?;
91+
92+
Ok(roles.contains(&"pa_admin".to_string()))
93+
}

0 commit comments

Comments
 (0)