Index: openacs-4/packages/acs-authentication/tcl/local-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/local-procs.tcl,v diff -u -r1.41 -r1.42 --- openacs-4/packages/acs-authentication/tcl/local-procs.tcl 29 Dec 2017 10:46:39 -0000 1.41 +++ openacs-4/packages/acs-authentication/tcl/local-procs.tcl 29 Dec 2017 11:22:07 -0000 1.42 @@ -21,27 +21,27 @@ ##### ad_proc -private auth::local::install {} { - Register local service contract implementations, + Register local service contract implementations, and update the local authority with live information. } { db_transaction { # Register the local service contract implementations set row(auth_impl_id) [auth::local::authentication::register_impl] set row(pwd_impl_id) [auth::local::password::register_impl] set row(register_impl_id) [auth::local::registration::register_impl] - set row(user_info_impl_id) [auth::local::user_info::register_impl] + set row(user_info_impl_id) [auth::local::user_info::register_impl] # Set the authority pretty-name to be the system name set row(pretty_name) [ad_system_name] - + auth::authority::edit \ -authority_id [auth::authority::local] \ -array row } } ad_proc -private auth::local::uninstall {} { - Unregister the local service contract implementation, and update the + Unregister the local service contract implementation, and update the local authority to reflect that. } { db_transaction { @@ -75,7 +75,7 @@ ad_proc -private auth::local::authentication::register_impl {} { Register the 'local' implementation of the 'auth_authentication' service contract. - + @return impl_id of the newly created implementation. } { set spec { @@ -110,25 +110,25 @@ } { ns_log Notice "Starting auth::local::authentication::MergeUser" db_transaction { - ns_log Notice " Merging user portraits" + ns_log Notice " Merging user portraits" - ns_log notice " Merging username, email and basic info in general" + ns_log notice " Merging username, email and basic info in general" - set new_username "merged_$from_user_id" - append new_username "_$to_user_id" - - # Shall we keep the domain for email? - # Actually, the username 'merged_xxx_yyy' - # won't be an email, so we will keep it without - # domain - set new_email $new_username - - set rel_id [db_string getrelid {}] - membership_rel::change_state -rel_id $rel_id -state "merged" - - acs_user::update -user_id $from_user_id -username "$new_username" -screen_name "$new_username" - party::update -party_id $from_user_id -email "$new_email" - + set new_username "merged_$from_user_id" + append new_username "_$to_user_id" + + # Shall we keep the domain for email? + # Actually, the username 'merged_xxx_yyy' + # won't be an email, so we will keep it without + # domain + set new_email $new_username + + set rel_id [db_string getrelid {}] + membership_rel::change_state -rel_id $rel_id -state "merged" + + acs_user::update -user_id $from_user_id -username "$new_username" -screen_name "$new_username" + party::update -party_id $from_user_id -email "$new_email" + } ns_log notice "Finishing auth::local::authentication::MergeUser" } @@ -140,13 +140,13 @@ {parameters {}} {authority_id {}} } { - Implements the Authenticate operation of the auth_authentication + Implements the Authenticate operation of the auth_authentication service contract for the local account implementation. } { array set auth_info [list] if {$authority_id eq ""} { - set authority_id [auth::authority::local] + set authority_id [auth::authority::local] } set user_id [acs_user::get_by_username -authority_id $authority_id -username $username] @@ -163,15 +163,15 @@ return [array get auth_info] } - # We set 'external' account status to 'ok', because the + # We set 'external' account status to 'ok', because the # local account status will be checked anyways by the framework set auth_info(account_status) ok return [array get auth_info] } ad_proc -private auth::local::authentication::GetParameters {} { - Implements the GetParameters operation of the auth_authentication + Implements the GetParameters operation of the auth_authentication service contract for the local account implementation. } { # No parameters @@ -190,7 +190,7 @@ ad_proc -private auth::local::password::register_impl {} { Register the 'local' implementation of the 'auth_password' service contract. - + @return impl_id of the newly created implementation. } { set spec { @@ -221,7 +221,7 @@ ad_proc -private auth::local::password::CanChangePassword { {parameters ""} } { - Implements the CanChangePassword operation of the auth_password + Implements the CanChangePassword operation of the auth_password service contract for the local account implementation. } { # Yeah, we can change your password @@ -231,7 +231,7 @@ ad_proc -private auth::local::password::CanRetrievePassword { {parameters ""} } { - Implements the CanRetrievePassword operation of the auth_password + Implements the CanRetrievePassword operation of the auth_password service contract for the local account implementation. } { # passwords are stored hashed, so we send the hash and let the user choose a new password @@ -241,7 +241,7 @@ ad_proc -private auth::local::password::CanResetPassword { {parameters ""} } { - Implements the CanResetPassword operation of the auth_password + Implements the CanResetPassword operation of the auth_password service contract for the local account implementation. } { # Yeah, we can reset for you. @@ -255,12 +255,12 @@ {parameters {}} {authority_id {}} } { - Implements the ChangePassword operation of the auth_password + Implements the ChangePassword operation of the auth_password service contract for the local account implementation. } { - array set result { + array set result { password_status {} - password_message {} + password_message {} } set user_id [acs_user::get_by_username -authority_id $authority_id -username $username] @@ -270,10 +270,10 @@ } if { $old_password ne "" } { - if { ![ad_check_password $user_id $old_password] } { - set result(password_status) "old_password_bad" - return [array get result] - } + if { ![ad_check_password $user_id $old_password] } { + set result(password_status) "old_password_bad" + return [array get result] + } } ad_try { @@ -287,43 +287,43 @@ set result(password_status) "ok" if { [parameter::get -parameter EmailAccountOwnerOnPasswordChangeP -package_id [ad_acs_kernel_id] -default 1] } { - ad_try { - acs_user::get -username $username -authority_id $authority_id -array user - - set system_name [ad_system_name] - set pvt_home_name [ad_pvt_home_name] - set password_update_link_text [_ acs-subsite.Change_my_Password] - - if { [auth::UseEmailForLoginP] } { - set account_id_label [_ acs-subsite.Email] - set account_id $user(email) - } else { - set account_id_label [_ acs-subsite.Username] - set account_id $user(username) - } - - set subject [_ acs-subsite.Password_changed_subject] - set body [_ acs-subsite.Password_changed_body] - - acs_mail_lite::send \ + ad_try { + acs_user::get -username $username -authority_id $authority_id -array user + + set system_name [ad_system_name] + set pvt_home_name [ad_pvt_home_name] + set password_update_link_text [_ acs-subsite.Change_my_Password] + + if { [auth::UseEmailForLoginP] } { + set account_id_label [_ acs-subsite.Email] + set account_id $user(email) + } else { + set account_id_label [_ acs-subsite.Username] + set account_id $user(username) + } + + set subject [_ acs-subsite.Password_changed_subject] + set body [_ acs-subsite.Password_changed_body] + + acs_mail_lite::send \ -send_immediately \ -to_addr $user(email) \ -from_addr [ad_outgoing_sender] \ -subject $subject \ -body $body - } on error {errorMsg} { + } on error {errorMsg} { ad_log Error "Error sending out password changed notification to account owner with user_id $user(user_id), email $user(email): $errorMsg" - } + } } - + return [array get result] } ad_proc -private auth::local::password::RetrievePassword { username parameters } { - Implements the RetrievePassword operation of the auth_password + Implements the RetrievePassword operation of the auth_password service contract for the local account implementation. } { set result(password_status) "ok" @@ -352,12 +352,12 @@ {authority_id {}} {new_password {}} } { - Implements the ResetPassword operation of the auth_password + Implements the ResetPassword operation of the auth_password service contract for the local account implementation. } { - array set result { + array set result { password_status ok - password_message {} + password_message {} } set user_id [acs_user::get_by_username -authority_id $authority_id -username $username] @@ -368,9 +368,9 @@ # Reset the password if { $new_password ne "" } { - set password $new_password + set password $new_password } else { - set password [ad_generate_random_string] + set password [ad_generate_random_string] } ad_change_password $user_id $password @@ -403,7 +403,7 @@ ad_proc -private auth::local::registration::register_impl {} { Register the 'local' implementation of the 'auth_registration' service contract. - + @return impl_id of the newly created implementation. } { set spec { @@ -434,7 +434,7 @@ } { set result(required) {} if { ![auth::UseEmailForLoginP] } { - set result(required) username + set result(required) username } lappend result(required) email first_names last_name @@ -444,9 +444,9 @@ lappend result(optional) password } - if { [parameter::get -package_id [ad_acs_kernel_id] -parameter RequireQuestionForPasswordResetP -default 0] && + if { [parameter::get -package_id [ad_acs_kernel_id] -parameter RequireQuestionForPasswordResetP -default 0] && [parameter::get -package_id [ad_acs_kernel_id] -parameter UseCustomQuestionForPasswordReset -default 0] } { - lappend result(required) secret_question secret_answer + lappend result(required) secret_question secret_answer } return [array get result] @@ -505,28 +505,28 @@ -parameter EmailRegistrationConfirmationToUserP \ -package_id [ad_conn subsite_id] -default 1]] != 0 } { - if { $generated_pwd_p + if { $generated_pwd_p || [parameter::get \ -parameter RegistrationProvidesRandomPasswordP \ -package_id [ad_conn subsite_id] -default 0] || $email_reg_confirm_p } { - ad_try { - auth::password::email_password \ - -username $username \ - -authority_id $authority_id \ - -password $password \ - -from [parameter::get \ + ad_try { + auth::password::email_password \ + -username $username \ + -authority_id $authority_id \ + -password $password \ + -from [parameter::get \ -parameter NewRegistrationEmailAddress \ -package_id [ad_conn subsite_id] \ -default [ad_system_owner]] \ - -subject_msg_key "acs-subsite.email_subject_Registration_password" \ - -body_msg_key "acs-subsite.email_body_Registration_password" - } on error {errorMsg} { - # We don't fail hard here, just log an error - ad_log Error "Error sending registration confirmation to $email: $errorMsg" - } - } + -subject_msg_key "acs-subsite.email_subject_Registration_password" \ + -body_msg_key "acs-subsite.email_body_Registration_password" + } on error {errorMsg} { + # We don't fail hard here, just log an error + ad_log Error "Error sending registration confirmation to $email: $errorMsg" + } + } } # LARS TODO: Move this out of the local driver and into the auth framework @@ -575,8 +575,8 @@ # ad_proc -private auth::local::user_info::register_impl {} { - Register the 'local' implementation of the 'auth_user_info' service contract. - + Register the 'local' implementation of the 'auth_user_info' service contract. + @return impl_id of the newly created implementation. } { set spec { @@ -632,7 +632,7 @@ set results [list] db_foreach user_search {} { - lappend results $user_id + lappend results $user_id } return $results