Merged PR 1156: Fix: Prevent duplicate usernames across all user states
Fix: Prevent duplicate usernames across all user states Changes: - Updated username duplicate validation to consider all existing users. - Prevented reuse of usernames belonging to deleted/disabled accounts. - Fixed authentication conflicts caused by duplicate usernames. Fixes #1809 Related work items: #1809
This commit is contained in:
@@ -116,15 +116,13 @@ bool util::isPasswordValid(const std::string& password)
|
||||
* usersMap - map of user objects keyed by identifier
|
||||
* Returns:
|
||||
* bool - true if the username is already in use by an active user, false otherwise
|
||||
* Notes:
|
||||
* - Only considers users with state util::State::ACTIVE
|
||||
*/
|
||||
bool util::isUsernameDuplicate(const std::string& username, const util::Map<std::string, User*>& usersMap)
|
||||
{
|
||||
int index = usersMap.findIf(
|
||||
[&](const std::string&, User* user)
|
||||
{
|
||||
return (user->getUserName() == username && user->getState() == util::State::ACTIVE);
|
||||
return (user->getUserName() == username);
|
||||
}
|
||||
);
|
||||
return index != -1;
|
||||
|
||||
Reference in New Issue
Block a user