diff options
author | xue <> | 2008-01-13 16:26:15 +0000 |
---|---|---|
committer | xue <> | 2008-01-13 16:26:15 +0000 |
commit | b17bafab4b6690836d37a547ed1ff13c757718d5 (patch) | |
tree | cf359e82fdd6a0140c7fbcc07bae12883837f4d2 | |
parent | ce3f545db83dd09dfee42647a747e2ff4c4d7863 (diff) |
Added TAuthManager.switchUser()
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | framework/Security/TAuthManager.php | 15 |
2 files changed, 16 insertions, 0 deletions
@@ -19,6 +19,7 @@ ENH: Active Record now supports implicitly declared related properties (Qiang) ENH: Active Record now supports query criteria for implicitly declared related properties (Qiang) ENH: TDataFieldAccessor now supports chained property access without getters. (Qiang) ENH: TParameterModule added caching support (Qiang) +ENH: Added TAuthManager.switchUser() (Qiang) NEW: Added TDbLogRoute (Qiang) NEW: Added TDataRenderer and TItemDataRenderer (Qiang) NEW: Ticket#544 - Added TXCache (Wei) 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 @@ -337,6 +337,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.
* If yes, a user object will be created for the application.
|