subsite::confirm_email_change (private)
subsite::confirm_email_change user_id token
Defined in packages/acs-subsite/tcl/email-change-procs.tcl
Apply a pending email change for this account. Return 1 on success and 0 if the request is invalid or no longer applicable.
- Parameters:
- user_id (required)
- token (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: if {![regexp {^[0-9a-f]{64}$} $token]} { return 0 } set digest [ns_crypto::md string -digest sha256 -encoding hex $token] set confirmed 0 db_transaction { # Both request and confirmation lock the same party first. set current_email [db_string email_change_confirm_lock_party { select email from parties where party_id = :user_id for update }] set now [clock seconds] if {[db_0or1row email_change_find_pending { select old_email, new_email from subsite_email_changes where user_id = :user_id and token_digest = :digest and expires_at > :now }] && $current_email eq $old_email} { acs_user::get -user_id $user_id -array user if {"email" ni [auth::sync::get_sync_elements -authority_id $user(authority_id)] && [party::get_by_email_not_cached -email $new_email] eq ""} { array set update [list email $new_email email_verified_p t] set result [auth::update_local_account -authority_id $user(authority_id) -username $user(username) -array update] if {[dict get $result update_status] eq "ok"} { if {[dict get $result user_id] != $user_id} { error "Account changed during email confirmation" } db_dml email_change_consume_pending { delete from subsite_email_changes where user_id = :user_id } set confirmed 1 } } } } if {$confirmed} { catch {email_image::edit_email_image -user_id $user_id -new_email $new_email} } return $confirmedXQL Not present: Generic, PostgreSQL, Oracle