Skip to content

Commit 2b9e72d

Browse files
committed
closes #216
1 parent 8c6ee40 commit 2b9e72d

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

contracts/user_management/src/functions/get_user_by_id.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,21 @@ use crate::error::{handle_error, Error};
77
use crate::schema::{DataKey, UserProfile};
88
use core::iter::Iterator;
99

10-
10+
/// Retrieves a user profile by user ID.
11+
///
12+
/// # Arguments
13+
///
14+
/// * `env` - Soroban environment.
15+
/// * `requester` - The address of the requester (must be authenticated).
16+
/// * `user_id` - The address of the user whose profile is to be retrieved.
17+
///
18+
/// # Returns
19+
///
20+
/// * `UserProfile` - The user profile associated with the provided user ID.
21+
///
22+
/// # Panics
23+
///
24+
/// * Panics if the requester is not authorized or if the profile does not exist.
1125
pub fn get_user_by_id(env: Env, requester: Address, user_id: Address) -> UserProfile {
1226
// Require authentication for the requester
1327
requester.require_auth();
@@ -28,6 +42,16 @@ pub fn get_user_by_id(env: Env, requester: Address, user_id: Address) -> UserPro
2842
profile
2943
}
3044

45+
/// Checks whether the given address is an admin.
46+
///
47+
/// # Arguments
48+
///
49+
/// * `env` - Soroban environment.
50+
/// * `who` - The address to check for admin status.
51+
///
52+
/// # Returns
53+
///
54+
/// * `bool` - True if the address is an admin, otherwise false.
3155
fn is_admin(env: &Env, who: &Address) -> bool {
3256
// Use the secure admin check from admin_management module
3357
use crate::schema::AdminConfig;

0 commit comments

Comments
 (0)