Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions contracts/user_management/src/functions/admin_management.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2025 SkillCert

use crate::schema::{AdminConfig, DataKey};
use soroban_sdk::{Address, Env, Vec, Symbol, symbol_short};

use crate::error::{handle_error, Error};
Expand All @@ -13,6 +14,7 @@ const INIT_SYSTEM_EVENT: Symbol = symbol_short!("initSys");
const ADD_ADMIN_EVENT: Symbol = symbol_short!("addAdmin");
const REMOVE_ADMIN_EVENT: Symbol = symbol_short!("rmvAdmin");


/// Initialize the admin system - can only be called once
pub fn initialize_system(
env: Env,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use crate::error::{handle_error, Error};
use crate::schema::{DataKey, LightProfile, UserProfile, UserRole, UserStatus};
use crate::error::{Error, handle_error};
use core::iter::Iterator;
use soroban_sdk::{symbol_short, Address, Env, String, Symbol, Vec};

Expand Down
1 change: 1 addition & 0 deletions contracts/user_management/src/functions/delete_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use crate::error::{handle_error, Error};
use crate::schema::{AdminConfig, DataKey, LightProfile, UserProfile, UserStatus};
use crate::error::{Error, handle_error};
use core::iter::Iterator;
use soroban_sdk::{symbol_short, Address, Env, Symbol};

Expand Down
2 changes: 2 additions & 0 deletions contracts/user_management/src/functions/get_user_by_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use soroban_sdk::{Address, Env};

use crate::error::{handle_error, Error};
use crate::schema::{DataKey, UserProfile};
use crate::error::{Error, handle_error};
use soroban_sdk::{symbol_short, Address, Env, Symbol};
use core::iter::Iterator;

/// Get User by ID
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2025 SkillCert


use crate::schema::{AdminConfig, DataKey, LightProfile, UserRole, UserStatus};
use soroban_sdk::{Address, Env, String, Vec};

use crate::error::{handle_error, Error};
Expand Down
25 changes: 25 additions & 0 deletions contracts/user_management/src/functions/save_profile.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2025 SkillCert

use crate::schema::{DataKey, LightProfile, UserProfile, UserRole, UserStatus};
use crate::error::{Error, handle_error};
use soroban_sdk::{Address, Env, String, Vec};

/// Security constants for profile validation
const MAX_NAME_LENGTH: usize = 100;
const MAX_EMAIL_LENGTH: usize = 320; // RFC 5321 standard
const MAX_SPECIALIZATION_LENGTH: usize = 100;
const MAX_LANGUAGE_LENGTH: usize = 50;
const MAX_CATEGORY_LENGTH: usize = 100;
const MAX_PASSWORD_LENGTH: usize = 128;
const MIN_PASSWORD_LENGTH: usize = 8;

/// Validates string content for security
fn validate_string_content(_env: &Env, s: &String, max_len: usize) -> bool {
if s.len() > max_len as u32 {
return false;
}

// For no_std environment, we'll do basic length validation
// More sophisticated pattern matching can be added if needed
true
}

pub fn user_management_save_profile(
use crate::error::{handle_error, Error};
use crate::schema::{
UserProfile,
Expand Down