File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ pub enum ACTION {
5252 GetCanonicalInfoHash ,
5353 ChangePassword ,
5454 BanUser ,
55+ GetUsers ,
5556}
5657
5758pub struct Service {
@@ -248,6 +249,7 @@ impl Default for CasbinConfiguration {
248249 admin, GetCanonicalInfoHash
249250 admin, ChangePassword
250251 admin, BanUser
252+ admin, GetUsers
251253 registered, GetAboutPage
252254 registered, GetLicensePage
253255 registered, GetCategories
Original file line number Diff line number Diff line change @@ -321,6 +321,28 @@ impl BanService {
321321 }
322322}
323323
324+ pub struct ListingService {
325+ user_profile_repository : Arc < DbUserProfileRepository > ,
326+ authorization_service : Arc < authorization:: Service > ,
327+ }
328+
329+ impl ListingService {
330+ /// Gets all users.
331+ ///
332+ /// # Errors
333+ ///
334+ /// This function will return a:
335+ ///
336+ /// * There is a database error retrieving the users
337+ pub async fn get_all ( & self , maybe_user_id : Option < UserId > ) -> Result < Vec < UserProfile > , ServiceError > {
338+ self . authorization_service . authorize ( ACTION :: GetUsers , maybe_user_id) . await ?;
339+
340+ let users = self . user_profile_repository . get_all_user_profiles ( ) . await ?;
341+
342+ Ok ( users)
343+ }
344+ }
345+
324346#[ cfg_attr( test, automock) ]
325347#[ async_trait]
326348pub trait Repository : Sync + Send {
You can’t perform that action at this time.
0 commit comments