From b17bafab4b6690836d37a547ed1ff13c757718d5 Mon Sep 17 00:00:00 2001 From: xue <> Date: Sun, 13 Jan 2008 16:26:15 +0000 Subject: Added TAuthManager.switchUser() --- framework/Security/TAuthManager.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'framework/Security') diff --git a/framework/Security/TAuthManager.php b/framework/Security/TAuthManager.php index 03f011c6..eab82e56 100644 --- a/framework/Security/TAuthManager.php +++ b/framework/Security/TAuthManager.php @@ -336,6 +336,21 @@ class TAuthManager extends TModule } } + /** + * Switches to a new user. + * This method will logout the current user first and login with a new one (without password.) + * @param string the new username + * @return boolean if the switch is successful + */ + public function switchUser($username) + { + if(($user=$this->_userManager->getUser($username))===null) + return false; + $this->updateSessionUser($user); + $this->getApplication()->setUser($user); + return true; + } + /** * Logs in a user with username and password. * The username and password will be used to validate if login is successful. -- cgit v1.2.3