Skip to content

Commit f4019b4

Browse files
refactor
1 parent 33ccd47 commit f4019b4

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

src/handlers/http/modal/query/querier_rbac.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ pub async fn post_user(
7171
}
7272
}
7373
let _guard = UPDATE_LOCK.lock().await;
74-
if Users.contains(&username) && Users.contains(&username)
75-
|| metadata.users.iter().any(|user| match &user.ty {
76-
UserType::Native(basic) => basic.username == username,
77-
UserType::OAuth(_) => false, // OAuth users should be created differently
78-
})
74+
if Users.contains(&username)
75+
|| metadata
76+
.users
77+
.iter()
78+
.any(|user| matches!(&user.ty, UserType::Native(basic) if basic.username == username))
7979
{
8080
return Err(RBACError::UserExists);
8181
}

src/handlers/http/rbac.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ pub async fn post_gen_password(username: web::Path<String>) -> Result<impl Respo
185185
// Handler for GET /api/v1/user/{userid}/role
186186
// returns role for a user if that user exists
187187
pub async fn get_role(userid: web::Path<String>) -> Result<impl Responder, RBACError> {
188+
let userid = userid.into_inner();
188189
if !Users.contains(&userid) {
189190
return Err(RBACError::UserDoesNotExist);
190191
};

src/rbac/user.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@ impl User {
6969
pub fn new_oauth(userid: String, roles: HashSet<String>, user_info: UserInfo) -> Self {
7070
Self {
7171
ty: UserType::OAuth(OAuth {
72-
userid: user_info
73-
.sub
74-
.clone()
75-
.or_else(|| user_info.name.clone())
76-
.unwrap_or(userid),
72+
userid: user_info.sub.clone().unwrap_or(userid),
7773
user_info,
7874
}),
7975
roles,

0 commit comments

Comments
 (0)