auth::create_local_account_helper (private)

 auth::create_local_account_helper email first_names last_name password \
    password_question password_answer [ url ] [ email_verified_p ] \
    [ member_state ] [ user_id ] [ username ] [ authority_id ] \
    [ screen_name ]

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

Creates a new user in the system. The user_id can be specified as an argument to enable double click protection. If this procedure succeeds, returns the new user_id. Otherwise, returns 0.

Parameters:
email (required)
first_names (required)
last_name (required)
password (required)
password_question (required)
password_answer (required)
url (optional)
email_verified_p (optional, defaults to "t")
member_state (optional, defaults to "approved")
user_id (optional)
username (optional)
authority_id (optional)
screen_name (optional)
See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 auth::create_local_account auth::create_local_account (public) auth::create_local_account_helper auth::create_local_account_helper auth::create_local_account->auth::create_local_account_helper acs_user_extension::user_new acs_user_extension::user_new (public) auth::create_local_account_helper->acs_user_extension::user_new ad_conn ad_conn (public) auth::create_local_account_helper->ad_conn ad_log ad_log (public) auth::create_local_account_helper->ad_log ad_try ad_try (public) auth::create_local_account_helper->ad_try db_dml db_dml (public) auth::create_local_account_helper->db_dml

Testcases:
No testcase defined.
Source code:
    if { $user_id eq "" } {
        set user_id [db_nextval acs_object_id_seq]
    }

    set creation_user ""
    set peeraddr ""

    # This may fail, either because there's no connection, or because
    # we're in the bootstrap-installer, at which point [ad_conn user_id] is undefined.
    ad_try {
        set creation_user [ad_conn user_id]
        set peeraddr [ad_conn peeraddr]
    } on error {errorMsg} {
        ns_log warning "auth::create_local_account_helper $errorMsg"
    }

    set salt [sec_random_token]
    set hashed_password [ns_sha1 "$password$salt"]

    set error_p 0
    db_transaction {

        set user_id [db_exec_plsql user_insert {}]

        # set password_question, password_answer
        db_dml update_question_answer {}

        ad_try {
            # Call the extension
            acs_user_extension::user_new -user_id $user_id
        } on error {errorMsg} {
            # At this point, we don't want the user addition to fail
            # if some extension is screwing things up
            ns_log warning "acs_user_extension::user_new -user_id $user_id failed: $errorMsg"
        }

    } on_error {
        # we got an error.  log it and signal failure.
        ad_log Error "Problem creating a new user"
        set error_p 1
    }

    if { $error_p } {
        return 0
    }
    # success.
    return $user_id
Generic XQL file:
<fullquery name="auth::create_local_account_helper.update_question_answer">
    <querytext>

            update users
            set    password_question = :password_question,
                   password_answer = :password_answer
            where  user_id = :user_id

      </querytext>
</fullquery>
packages/acs-authentication/tcl/authentication-procs.xql

PostgreSQL XQL file:
<fullquery name="auth::create_local_account_helper.user_insert">
    <querytext>
            select acs__add_user(
                :user_id,
                'user',
                now(),
                null,
                :peeraddr,
                :authority_id,
                :username,
                :email,
                :url,
                :first_names,
                :last_name,
                :hashed_password,
                :salt,
                :screen_name,
                :email_verified_p,
                :member_state
            );
      </querytext>
</fullquery>
packages/acs-authentication/tcl/authentication-procs-postgresql.xql

Oracle XQL file:
<fullquery name="auth::create_local_account_helper.user_insert">
    <querytext>
      
	begin
	    :1 := acs.add_user(
                user_id => :user_id,
		email => :email,
		url => :url,
                authority_id => :authority_id,
		username => :username,
		first_names => :first_names,
		last_name => :last_name,
		screen_name => :screen_name,
		password => :hashed_password,
	        salt => :salt,
                creation_user => :creation_user,
	        creation_ip => :peeraddr,
	        email_verified_p => :email_verified_p,
	        member_state => :member_state
            );
	end;
	
      </querytext>
</fullquery>
packages/acs-authentication/tcl/authentication-procs-oracle.xql

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