Skip to content

Commit d90b411

Browse files
authored
Merge pull request #221 from Pfed-prog/main
closes #214
2 parents 6e7cc78 + 0ea64f9 commit d90b411

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

contracts/user_management/src/functions/delete_user.rs

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,17 @@ use soroban_sdk::{symbol_short, Address, Env, Symbol};
99
// Event symbol for user deactivation
1010
const USER_DEACTIVATED_EVENT: Symbol = symbol_short!("usrDeact");
1111

12-
12+
/// Deletes a user by marking their status as inactive.
13+
///
14+
/// # Arguments
15+
///
16+
/// * `env` - The environment in which the operation is performed.
17+
/// * `caller` - The address of the caller initiating the deletion.
18+
/// * `user_id` - The address of the user to be deleted.
19+
///
20+
/// # Returns
21+
///
22+
/// * Result<(), Error> - Success if the user is deleted; otherwise returns an error.
1323
pub fn delete_user(env: Env, caller: Address, user_id: Address) {
1424
// Require authentication for the caller
1525
caller.require_auth();
@@ -55,7 +65,16 @@ pub fn delete_user(env: Env, caller: Address, user_id: Address) {
5565
.publish((USER_DEACTIVATED_EVENT, &caller), user_id.clone());
5666
}
5767

58-
/// Check if the caller is an admin
68+
/// Checks if the caller is an admin.
69+
///
70+
/// # Arguments
71+
///
72+
/// * `env` - The environment to query the admin configuration.
73+
/// * `who` - The address of the caller to check.
74+
///
75+
/// # Returns
76+
///
77+
/// * `bool` - True if the caller is an admin; otherwise, false.
5978
fn is_admin(env: &Env, who: &Address) -> bool {
6079
// Check if system is initialized
6180
let config: Option<AdminConfig> = env.storage().persistent().get(&DataKey::AdminConfig);
@@ -80,7 +99,16 @@ fn is_admin(env: &Env, who: &Address) -> bool {
8099
}
81100
}
82101

83-
/// Validate that a user exists by checking their profile
102+
/// Validates that a user exists by checking their profile.
103+
///
104+
/// # Arguments
105+
///
106+
/// * `env` - The environment in which the operation is performed.
107+
/// * `user_id` - The address of the user to validate.
108+
///
109+
/// # Returns
110+
///
111+
/// * `Result<UserProfile, ()>` - Ok containing UserProfile if the user exists; otherwise, an error.
84112
fn validate_user_exists(env: &Env, user_id: &Address) -> Result<UserProfile, ()> {
85113
env.storage()
86114
.persistent()

0 commit comments

Comments
 (0)