File tree Expand file tree Collapse file tree 3 files changed +7
-10
lines changed Expand file tree Collapse file tree 3 files changed +7
-10
lines changed Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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
187187pub 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 } ;
Original file line number Diff line number Diff 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,
You can’t perform that action at this time.
0 commit comments