xo::ProtocolHandler instproc set_user_id (public)
<instance of xo::ProtocolHandler> set_user_id
Defined in /var/www/openacs.org/packages/xotcl-core/tcl/50-protocol-handler-procs.tcl
Set user_id based on authentication header
- Testcases:
- No testcase defined.
Source code: :log "[ns_conn method] request comes with headers [ns_set array [ns_conn headers]]" set ah [ns_set iget [ns_conn headers] Authorization] if {$ah ne ""} { # # Get credentials from a basic authentication string like # "Basic 29234k3j49a". # set credentials [http_auth::basic_authentication_decode $ah] set auth [auth::authenticate -username [dict get $credentials user] -authority_id [::auth::get_register_authority] -password [dict get $credentials password]] if {[dict get $auth auth_status] ne "ok"} { set auth [auth::authenticate -email [dict get $credentials user] -password [dict get $credentials password]] if {[dict get $auth auth_status] ne "ok"} { :log "auth status [dict get $auth auth_status]" set :user_id 0 throw {AUTH UNAUTHORIZED {unauthorized}} [dict get $auth auth_status] } } :log "auth_check user_id='[dict get $auth user_id]'" ad_conn -set user_id [dict get $auth user_id] } else { # no authenticate header, anonymous visitor ad_conn -set user_id 0 ad_conn -set untrusted_user_id 0 } set :user_id [ad_conn user_id]XQL Not present: Generic, PostgreSQL, Oracle