@@ -31,7 +31,7 @@ use crate::{
31
31
rbac:: { InvalidUserGroupError , RBACError } ,
32
32
} ,
33
33
parseable:: PARSEABLE ,
34
- rbac:: map:: { read_user_groups, roles, users} ,
34
+ rbac:: map:: { mut_sessions , read_user_groups, roles, users} ,
35
35
} ;
36
36
37
37
#[ derive( Debug , Clone , PartialEq , Eq , serde:: Serialize , serde:: Deserialize ) ]
@@ -266,6 +266,10 @@ impl UserGroup {
266
266
267
267
pub fn add_roles ( & mut self , roles : HashSet < String > ) -> Result < ( ) , RBACError > {
268
268
self . roles . extend ( roles) ;
269
+ // also refresh all user sessions
270
+ for username in & self . users {
271
+ mut_sessions ( ) . remove_user ( username) ;
272
+ }
269
273
Ok ( ( ) )
270
274
}
271
275
@@ -283,6 +287,10 @@ impl UserGroup {
283
287
}
284
288
self . roles . clone_from ( & new_roles) ;
285
289
290
+ // also refresh all user sessions
291
+ for username in & self . users {
292
+ mut_sessions ( ) . remove_user ( username) ;
293
+ }
286
294
Ok ( ( ) )
287
295
}
288
296
@@ -293,6 +301,10 @@ impl UserGroup {
293
301
if old_users. eq ( & new_users) {
294
302
return Ok ( ( ) ) ;
295
303
}
304
+ // also refresh all user sessions
305
+ for username in & users {
306
+ mut_sessions ( ) . remove_user ( username) ;
307
+ }
296
308
self . users . clone_from ( & new_users) ;
297
309
298
310
Ok ( ( ) )
@@ -305,21 +317,4 @@ impl UserGroup {
305
317
put_metadata ( & metadata) . await ?;
306
318
Ok ( ( ) )
307
319
}
308
-
309
- // // are these methods even needed??
310
- // pub fn group_name(&self) -> String {
311
- // self.name.clone()
312
- // }
313
-
314
- // pub fn group_id(&self) -> Ulid {
315
- // self.id
316
- // }
317
-
318
- // pub fn group_roles(&self) -> HashSet<String> {
319
- // self.roles.clone()
320
- // }
321
-
322
- // pub fn group_users(&self) -> HashSet<String> {
323
- // self.users.clone()
324
- // }
325
320
}
0 commit comments