xo::Authorize method register_new_user (protected)

 <instance of xo::Authorize[i]> register_new_user \
    [ -first_names first_names ] [ -last_name last_name ] \
    [ -email email ]

Defined in packages/xooauth/tcl/authorize-procs.tcl

Register the user and return the user_id. In case, the registration of the new user fails, raise an exception. not tested

Switches:
-first_names
(optional)
-last_name
(optional)
-email
(optional)

Partial Call Graph (max 5 caller/called nodes):
%3 apm_package_installed_p apm_package_installed_p (public) auth::authority::local auth::authority::local (public) auth::create_local_account auth::create_local_account (public) db_transaction db_transaction (public) permission::grant permission::grant (public) xo::Authorize instproc register_new_user xo::Authorize instproc register_new_user xo::Authorize instproc register_new_user->apm_package_installed_p xo::Authorize instproc register_new_user->auth::authority::local xo::Authorize instproc register_new_user->auth::create_local_account xo::Authorize instproc register_new_user->db_transaction xo::Authorize instproc register_new_user->permission::grant

Testcases:
No testcase defined.
Source code:
db_transaction {
    set user_info(first_names) $first_names
    set user_info(last_name) $last_name
    if {![util_email_unique_p $email]} {
        error "Email is not unique: $email"
    }
    set user_info(email) $email
    array set creation_info [auth::create_local_account  -authority_id [auth::authority::local]  -username $email  -array user_info]
    if {$creation_info(creation_status) ne "ok"} {
        set errorMsg ""
        error [append errorMsg "Error when creating user: "  $creation_info(creation_status) " "  $creation_info(element_messages)]
    }

    set user_id $creation_info(user_id)
    :record_oauth_registration $user_id

    if {[apm_package_installed_p dotlrn] && ${:create_with_dotlrn_role} ne ""} {
        #
        # We have DotLRN installed, and we want to create
        # for this register object the new users in the
        # provided role. Note that one can define
        # different instances of this class behaving
        # differently.
        #
        dotlrn::user_add  -type ${:create_with_dotlrn_role}  -can_browse=1  -id $email  -user_id $user_id

        ::permission::grant  -party_id $user_id  -object_id [dotlrn::get_package_id]  -privilege read_private_data
    }
} on_error {
    ns_log error "OAuth Login (Error during user creation): $errmsg ($email)"
    error "OAuth user creation failed: $errmsg"
}
return $user_id
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: