@@ -8,6 +8,17 @@ use soroban_sdk::{symbol_short, Address, Env, Symbol, Vec};
88
99const ACCESS_LISTED_EVENT : Symbol = symbol_short ! ( "acListed" ) ;
1010
11+ /// Brief description: Checks if the given address is the creator of the course.
12+ ///
13+ /// # Arguments
14+ ///
15+ /// * `env` - Soroban environment reference used to access persistent storage.
16+ /// * `course_id` - The unique identifier of the course.
17+ /// * `who` - The address being checked against the stored creator.
18+ ///
19+ /// # Returns
20+ ///
21+ /// * `bool` - Returns `true` if the provided address is the creator of the course, otherwise `false`.
1122fn is_creator ( env : & Env , course_id : u128 , who : & Address ) -> bool {
1223 // Retrieve the creator address for the course from storage
1324 let creator: Address = env
@@ -18,6 +29,17 @@ fn is_creator(env: &Env, course_id: u128, who: &Address) -> bool {
1829 creator == * who
1930}
2031
32+ /// Brief description: Determines if a caller can list course access for a given course.
33+ ///
34+ /// # Arguments
35+ ///
36+ /// * `env` - Soroban environment reference for access control checks.
37+ /// * `caller` - The address requesting to list users with access.
38+ /// * `course_id` - The unique identifier of the course.
39+ ///
40+ /// # Returns
41+ ///
42+ /// * `bool` - Returns `true` if the caller is allowed to list access (creator, RBAC permission, or admin), otherwise `false`.
2143fn can_list_course_access ( env : & Env , caller : & Address , course_id : u128 ) -> bool {
2244 // Course creator always has access
2345 if is_creator ( env, course_id, caller) {
@@ -38,7 +60,19 @@ fn can_list_course_access(env: &Env, caller: &Address, course_id: u128) -> bool
3860 is_admin ( env, caller)
3961}
4062
41-
63+ /// Brief description: Lists all users who currently have access to a given course.
64+ ///
65+ /// # Arguments
66+ ///
67+ /// * `env` - Soroban environment instance used for authentication, storage, and events.
68+ /// * `caller` - The address requesting the access list; must be authorized and permitted.
69+ /// * `course_id` - The unique identifier of the course.
70+ ///
71+ /// # Returns
72+ ///
73+ /// * `Vec<Address>` - A list of addresses that currently have access to the specified course.
74+ /// On success, returns the list of user addresses.
75+ /// On failure, publishes an error event and may terminate execution with `Error::AccessDenied`.
4276pub fn list_users_with_access ( env : Env , caller : Address , course_id : u128 ) -> Vec < Address > {
4377 // Require the caller to be authenticated
4478 caller. require_auth ( ) ;
@@ -62,4 +96,4 @@ pub fn list_users_with_access(env: Env, caller: Address, course_id: u128) -> Vec
6296 ) ;
6397
6498 access_list
65- }
99+ }
0 commit comments