verify-password-setup.tcl

Verify a registration email before offering password setup.

Location:
/packages/acs-subsite/www/register/verify-password-setup.tcl

Related Files

[ hide source ] | [ make this the default ]

File Contents

ad_page_contract {
    Verify a registration email before offering password setup.
} {
    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 csrf_token [security::csrf::new]
switch -- [ns_conn method] {
    GET - HEAD {
        set form_fields [export_vars -form {token}]
    }
    POST {
        security::csrf::validate
        if {[catch {auth::local::password::verify_registration $token} setup_token]} {
            ns_log Error "Registration verification for password setup failed"
            ad_return_error "Verification failed" "The system could not verify your email address."
            ad_script_abort
        }
        if {$setup_token eq ""} {
            ad_return_complaint 1 "This verification link is invalid, expired, or already used."
            ad_script_abort
        }

        ad_returnredirect [export_vars -base /user/password-reset {{token $setup_token}}]
        ad_script_abort
    }
    default {
        template::require_post
    }
}

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