Index: openacs-4/packages/acs-subsite/www/register/recover-password.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/register/recover-password.tcl,v diff -u -r1.16 -r1.17 --- openacs-4/packages/acs-subsite/www/register/recover-password.tcl 18 Jun 2018 07:28:49 -0000 1.16 +++ openacs-4/packages/acs-subsite/www/register/recover-password.tcl 3 Sep 2024 15:37:34 -0000 1.17 @@ -32,61 +32,59 @@ ad_script_abort } +ad_form -name recover \ + -edit_buttons [list [list [_ acs-kernel.common_continue] ok]] \ + -form { {dummy:text(hidden),optional} } -# Display form to collect username and authority -set authority_options [auth::authority::get_authority_options] - -if { $authority_id eq "" } { - set authority_id [lindex $authority_options 0 1] -} - -ad_form -name recover -edit_buttons [list [list [_ acs-kernel.common_continue] ok]] -form { {dummy:text(hidden),optional} } - - - set username_widget text +set email_widget email if { [parameter::get -parameter UsePasswordWidgetForUsername -package_id [ad_acs_kernel_id]] } { set username_widget password + set email_widget password } set focus {} if { [auth::UseEmailForLoginP] } { - ad_form -extend -name recover -form [list [list email:text($username_widget) [list label [_ acs-subsite.Email]]]] + ad_form -extend -name recover -form [list [list email:text($email_widget) [list label [_ acs-subsite.Email]]]] set user_id_widget_name email set focus "email" } else { + set authority_options [auth::authority::get_authority_options] if { [llength $authority_options] > 1 } { ad_form -extend -name recover -form { - {authority_id:integer(select) - {label {[_ acs-kernel.authentication_authority]}} + {authority_id:integer(select) + {label {[_ acs-kernel.authentication_authority]}} {options $authority_options} } } } - - ad_form -extend -name recover -form [list [list username:text($username_widget) [list label [_ acs-subsite.Username]]]] -validate { - {username - { [acs_user::get_by_username -authority_id $authority_id -username $username] ne "" } - { Could not find username at authority } + + ad_form -extend -name recover \ + -form [list [list username:text($username_widget) [list label [_ acs-subsite.Username]]]] \ + -validate { + {username + { [acs_user::get_by_username -authority_id $authority_id -username $username] ne "" } + { Could not find username at authority } + } } - } set user_id_widget_name username set focus "username" } set focus "recover.$focus" - - - - set submission_p 0 ad_form -extend -name recover -on_request {} -# We handle form submission here, because otherwise we can't handle both the case where we use the form -# and the case where we don't in one go -if { [form is_valid recover] || (![form is_submission recover] && (([info exists username] && $username ne "") || ([info exists email] && $email ne ""))) } { +# +# We handle form submission here, because otherwise we can't handle +# both the case where we use the form and the case where we don't in +# one go. +# +if { [form is_valid recover] + || (![form is_submission recover] && ($username ne "" || $email ne "")) + } { array set recover_info [auth::password::recover_password \ -authority_id $authority_id \ -username $username \