password-reset.tcl

Let's the user reset his/her password.

Location:
/packages/acs-subsite/www/user/password-reset.tcl
CVS ID:
$Id: password-reset.tcl,v 1.10 2026/12/05 09:27:31 gustafn Exp $

Related Files

[ hide source ] | [ make this the default ]

File Contents

ad_page_contract {
    Let's the user reset his/her password.

    @cvs-id $Id: password-reset.tcl,v 1.10 2026/12/05 09:27:31 gustafn Exp $
} {
    token:word,notnull
}

ns_set iupdate [ns_conn outputheaders] Referrer-Policy no-referrer
ns_set iupdate [ns_conn outputheaders] Cache-Control no-store

if { [security::RestrictLoginToSSLP] } {
    security::require_secure_conn
}

set page_title [_ acs-subsite.Reset_Password]
set context [list [list [ad_pvt_home] [ad_pvt_home_name]] $page_title]

ad_form -name reset -action password-reset -export {token} \
    -csrf_protection_p 1 -edit_buttons [list [list [_ acs-subsite.Set_password] "ok"]] -form {
    {password_1:text(password)
        {label {[_ acs-subsite.New_Password]}}
        {html {size 20}}
    }
    {password_2:text(password)
        {label {[_ acs-subsite.Confirm]}}
        {html {size 20}}
    }
} -validate {
    {password_1
        { [string equal $password_1 $password_2] }
        { Passwords don't match }
    }
} -on_submit {

    set redeemed 0
    if {[ns_conn method] eq "POST"} {
        if {[catch {auth::local::password::complete_recovery $token $password_1} redeemed]} {
            ns_log Error "Local password recovery failed"
            form set_error reset password_1 [_ acs-subsite.Password_reset_failed]
            break
        }
    }
    if {!$redeemed} {
        form set_error reset password_1 [_ acs-subsite.Password_reset_link_invalid]
        break
    }

} -after_submit {
    ad_returnredirect -message [_ acs-subsite.confirmation_password_changed] [ad_get_login_url]
    ad_script_abort
}

# Local variables:
#    mode: tcl
#    tcl-indent-level: 4
#    indent-tabs-mode: nil
# End: