Revision: 1461
Author: magike.net
Date: Wed Jun 23 21:49:17 2010
Log: 给user组件增加simpleLogin接口,多用于插件
http://code.google.com/p/typecho/source/detail?r=1461

Modified:
  /trunk/var/Widget/User.php

=======================================
--- /trunk/var/Widget/User.php  Sun Mar  7 06:52:54 2010
+++ /trunk/var/Widget/User.php  Wed Jun 23 21:49:17 2010
@@ -158,6 +158,30 @@
          $this->pluginHandle()->loginFail($this, $name, $password,  
$temporarily, $expire);
          return false;
      }
+
+    /**
+     * 只需要提供uid即可登录的方法, 多用于插件等特殊场合
+     *
+     * @access public
+     * @param integer $uid 用户id
+     * @return boolean
+     */
+    public function simpleLogin($uid)
+    {
+        $user = $this->db->fetchRow($this->db->select()
+        ->from('table.users')
+        ->where('uid = ?', $uid)
+        ->limit(1));
+
+        if (empty($user)) {
+            return false;
+        }
+
+        $this->push($user);
+        $this->_hasLogin = true;
+
+        return true;
+    }

      /**
       * 用户登出函数
_______________________________________________
announce mailing list
[email protected]
http://lists.typecho.org/mailman/listinfo/announce

回复