Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

下次自动登录无效 #741

Closed
licxisky opened this issue Mar 31, 2018 · 2 comments
Closed

下次自动登录无效 #741

licxisky opened this issue Mar 31, 2018 · 2 comments

Comments

@licxisky
Copy link

licxisky commented Mar 31, 2018

1. 该问题的重现步骤是什么?

用户登录时,点击下次自动登录

2. 你期待的结果是什么?实际看到的又是什么?

本机再次登录时自动登录
再次登录时还是要输入用户名密码,无法自动登录

3. 问题出现的环境

  • 操作系统版本:Windows NT DESKTOP-AVTC9JU 10.0 build 16299 (Windows 10) i586
  • Apache/NGINX 版本:Apache/2.4.29 (Win32) OpenSSL/1.1.0g
  • 数据库版本:MySQL 5.6
  • PHP 版本: PHP/7.2.0
  • Typecho 版本:1.1 (17.10.30)
  • 浏览器版本:Chrome 65.0.3325.181(正式版本) (64 位)

4. 备注

看了一下Login.php的代码,似乎并没有在登录的时候从Cookie中取出以前存储的用户信息

@bestony
Copy link
Contributor

bestony commented Sep 6, 2018

有的, 在这一行检测是否登录

if ($user->hasLogin()) {

回溯到
Typecho_Widget::widget('Widget_User')->to($user);

最后定位到这个函数

typecho/var/Widget/User.php

Lines 219 to 242 in c2a71c2

public function hasLogin()
{
if (NULL !== $this->_hasLogin) {
return $this->_hasLogin;
} else {
$cookieUid = Typecho_Cookie::get('__typecho_uid');
if (NULL !== $cookieUid) {
/** 验证登陆 */
$user = $this->db->fetchRow($this->db->select()->from('table.users')
->where('uid = ?', intval($cookieUid))
->limit(1));
$cookieAuthCode = Typecho_Cookie::get('__typecho_authCode');
if ($user && Typecho_Common::hashValidate($user['authCode'], $cookieAuthCode)) {
$this->_user = $user;
return ($this->_hasLogin = true);
}
$this->logout();
}
return ($this->_hasLogin = false);
}
}

可以看到是有检查的。至于为什么你没有自动登录,可以下载一个 Cookie 编辑器,看一下登录时,是否有__typecho_uid这个 Cookie

@licxisky
Copy link
Author

谢谢,应该是之前有些操作的问题,TE本身没有问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants