Forum OpenACS Q&A: Re: on attempt to register, "'We already have a user with this username.' on element 'username'"

found the message in the subsite catalog:

./packages/acs-subsite/catalog/acs-subsite.en_US.ISO-8859-1.xml: <msg key="Have_user_name">We already have a user with this username.</msg>

and, found where the message key is used (only one place) at the end of auth::validate_account_info, in file packages/acs-authentication/tcl/authentication-procs.tcl, with the relevent code being:

ad_proc -private auth::validate_account_info {
    {-update:boolean}
    {-authority_id:required}
    {-username:required}
    {-user_array:required}
    {-message_array:required}
} { ... } {

    :
    :

    # (here is the end of the proc)

    # They're trying to set the username
    if { [exists_and_not_null user(username)] } {
        # Check that username is unique
        set username_user_id [acs_user::get_by_username -authority_id $authority_id -username $user(username)]

        if { $username_user_id ne "" && (!$update_p || $username_user_id != $user(user_id)) } {
            # We already have a user with this username, and either we're not updating, or it's not the same user_id as the one we're updating
            
            set username_member_state [acs_user::get_element -user_id $username_user_id -element member_state] 
            switch $username_member_state {
                banned {
                    # A user with this username does exist, but he's banned, so we can 'steal' his username
                    # by setting it to something dummy
                    acs_user::update \
                        -user_id $username_user_id \
                        -username "dummy-username-$username_user_id"
                }
                default { 
                    set element_messages(username) [_ acs-subsite.Have_user_name]
                }
            }
        }
    }
}