acs::test::set_user (private)
acs::test::set_user [ -session session ] user_info
Defined in packages/acs-automated-testing/tcl/aa-test-procs.tcl
When (login) cookies are given as member of "session", use these. In case the login cookie is empty (after an explicit logout) do NOT automatically log in. When (login) cookies are not given, use "user_info" for authentication. When we have a "user_id" and "address" in the "user_info", use these for direct logins. Otherwise the person info (name, email, ...) to log via register.
- Switches:
- -session (optional)
- when given, use login information from there
- Parameters:
- user_info (required)
- dict containing user_id+session and/or email, last_name, username and password
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: #aa_log "set_user has user_info $user_info, have cookies: [dict exists $session cookies]" set already_logged_in 0 # # First check, if the user is already logged in via cookies # if {[dict exists $session cookies]} { #aa_log "session has cookies '[dict get $session cookies]'" foreach cookie [split [dict get $session cookies] ";"] { lassign [split [string trim $cookie] =] name value #aa_log "session has cookie $cookie // NAME '$name' VALUE '$value'" if {$name in {ad_user_login ad_user_login_secure} && $value ne "\"\""} { aa_log "user is already logged in via cookie $name" set already_logged_in 1 dict set session login via_cookie break } } } #aa_log "already_logged_in $already_logged_in" if {!$already_logged_in} { # # The user is not logged in via cookies, check first # available user_id. If this does not exist, perform login # #aa_log "not logged in, check $user_info" if {[dict exists $user_info user_id] && [dict exists $user_info address] } { set user_id [dict get $user_info user_id] if {$user_id ne 0} { #aa_log "::acs::test::set_user set logindata via nsv" set address [dict get $user_info address] ad_try { set peeraddr [ns_addrbyhost $address] } on error {errorMsg} { set peeraddr $address } set address $peeraddr nsv_set aa_test logindata [list peeraddr $address user_id $user_id] dict set session login via_logindata } else { dict set session login none } } elseif {[dict exists $session cookies]} { # # We have cookies, but are not logged in. Do NOT automatically log in. # dict set session login none } else { # # No cookies, log automatically in. # #aa_log "::acs::test::set_user perform login with $user_info" set d [::acs::test::login $user_info] #aa_log "::acs::test::set_user perform login returned session [dict get $d session]" dict set session cookies [dict get $d session cookies] dict set session login via_login } } return $sessionXQL Not present: Generic, PostgreSQL, Oracle