auth::update_local_account (public)

 auth::update_local_account -authority_id authority_id \
    -username username -array array

Defined in packages/acs-authentication/tcl/authentication-procs.tcl

Update the local account for a user.

Switches:
-authority_id (required)
-username (required)
-array (required)
Name of an array containing the registration elements to update.
Returns:
Array list containing the following entries:
  • update_status: ok, data_error, update_error, failed_to_connect. Says whether user update succeeded.
  • update_message: Information about the problem, to be relayed to the user. If update_status is not ok, then either update_message or element_messages is guaranteed to be nonempty, and both are guaranteed to be in the array list. May contain HTML.
  • element_messages: list of (element_name, message, element_name, message, ...) of errors on the individual registration elements. to be relayed on to the user. If update_status is not ok, then either update_message or element_messages is guaranteed to be nonempty, and both are guaranteed to be in the array list. Cannot contain HTML.
All entries are guaranteed to always be set, but may be empty.

Partial Call Graph (max 5 caller/called nodes):
%3 test_auth__update_local_account auth__update_local_account (test acs-authentication) auth::update_local_account auth::update_local_account test_auth__update_local_account->auth::update_local_account _ _ (public) auth::update_local_account->_ acs_user::update acs_user::update (public) auth::update_local_account->acs_user::update ad_log ad_log (public) auth::update_local_account->ad_log ad_try ad_try (public) auth::update_local_account->ad_try auth::validate_account_info auth::validate_account_info (private) auth::update_local_account->auth::validate_account_info auth::sync::job::action auth::sync::job::action (public) auth::sync::job::action->auth::update_local_account packages/acs-subsite/lib/user-info.tcl packages/acs-subsite/ lib/user-info.tcl packages/acs-subsite/lib/user-info.tcl->auth::update_local_account

Testcases:
auth__update_local_account
Source code:
    upvar 1 $array user_info

    array set result {
        update_status update_error
        update_message {}
        element_messages {}
        user_id {}
    }

    # Validate data
    auth::validate_account_info  -update  -authority_id $authority_id  -username $username  -user_array user_info  -message_array element_messages

    # Handle validation errors
    if { [array size element_messages] > 0 } {
        return [list  update_status "data_error"  update_message {}  element_messages [array get element_messages]  ]
    }

    # We get user_id from validate_account_info above, and set it in the result array so our caller can get it
    set user_id $user_info(user_id)
    set result(user_id) $user_id

    ad_try {

        db_transaction {
            # Update persons: first_names, last_name
            if { [info exists user_info(first_names)] } {
                # We know that validate_account_info will not let us update only one of the two
                person::update  -person_id $user_id  -first_names $user_info(first_names)  -last_name $user_info(last_name)
            }

            # Update person's bio
            if { [info exists user_info(bio)] } {
                person::update  -person_id $user_id  -bio $user_info(bio)
            }

            # Update parties: email, url
            if { [info exists user_info(email)] } {
                party::update  -party_id $user_id  -email $user_info(email)
            }
            if { [info exists user_info(url)] } {
                party::update  -party_id $user_id  -url $user_info(url)
            }

            # Update users: email_verified_p
            if { [info exists user_info(email_verified_p)] } {
                acs_user::update  -user_id $user_id  -email_verified_p $user_info(email_verified_p)
            }

            # Update users: screen_name
            if { [info exists user_info(screen_name)] } {
                acs_user::update  -user_id $user_id  -screen_name $user_info(screen_name)
            }

            if { [info exists user_info(username)] } {
                acs_user::update  -user_id $user_id  -username $user_info(username)
            }

            if { [info exists user_info(authority_id)] } {
                acs_user::update  -user_id $user_id  -authority_id $user_info(authority_id)
            }

            # TODO: Portrait
        }
    } on error {errorMsg} {
        set result(update_status) "failed_to_connect"
        set result(update_message) [_ acs-subsite.Error_update_account_info]
        ad_log Error "Error updating local account: $errorMsg"
        return [array get result]
    }

    # Update succeeded
    set result(update_status) "ok"

    return [array get result]
Generic XQL file:
packages/acs-authentication/tcl/authentication-procs.xql

PostgreSQL XQL file:
packages/acs-authentication/tcl/authentication-procs-postgresql.xql

Oracle XQL file:
packages/acs-authentication/tcl/authentication-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: