@@ -45,7 +45,10 @@ pub async fn list_users() -> impl Responder {
45
45
// Creates a new user by username if it does not exists
46
46
// Otherwise make a call to reset password
47
47
// returns password generated for this user
48
- pub async fn put_user ( username : web:: Path < String > ) -> Result < impl Responder , RBACError > {
48
+ pub async fn put_user (
49
+ username : web:: Path < String > ,
50
+ body : Option < web:: Json < serde_json:: Value > > ,
51
+ ) -> Result < impl Responder , RBACError > {
49
52
let username = username. into_inner ( ) ;
50
53
validator:: user_name ( & username) ?;
51
54
if username == CONFIG . parseable . username {
@@ -60,13 +63,16 @@ pub async fn put_user(username: web::Path<String>) -> Result<impl Responder, RBA
60
63
// should be unreachable given state is always consistent
61
64
return Err ( RBACError :: UserExists ) ;
62
65
}
63
-
64
- let ( user, password) = User :: create_new ( username) ;
66
+ let ( user, password) = User :: create_new ( username. clone ( ) ) ;
65
67
metadata. users . push ( user. clone ( ) ) ;
66
68
put_metadata ( & metadata) . await ?;
67
69
// set this user to user map
68
70
Users . put_user ( user) ;
69
71
72
+ if let Some ( body) = body {
73
+ put_role ( web:: Path :: < String > :: from ( username) , body) . await ?;
74
+ }
75
+
70
76
Ok ( password)
71
77
}
72
78
}
0 commit comments