ProcessWire无法登录后台的终极解决方法

由于最新的一个项目需要经常做物理环境切换,所以不得不经常把数据两边迁移,在这个过程中发现了一个小问题记录一下处理方法。严格地讲这不是一个问题,而是由于我的疏忽没有认真查看更新说明而导致情况的发生。

问题表现为账户无法登录到后台,在logs/errors.txt记录下来的均为密码无效(invalid password)的错误。

在我仔细去官方翻阅资料,又检查config.php文件中的两个参数:

/**
 * Installer: User Authentication Salt 
 * 
 * This value was randomly generated for your system on 2020/12/02.
 * This should be kept as private as a password and never stored in the database.
 * Must be retained if you migrate your site from one server to another.
 * Do not change this value, or user passwords will no longer work.
 * 
 */
$config->userAuthSalt = 'secret string'; 

/**
 * Installer: Table Salt (General Purpose) 
 * 
 * Use this rather than userAuthSalt when a hashing salt is needed for non user 
 * authentication purposes. Like with userAuthSalt, you should never change 
 * this value or it may break internal system comparisons that use it. 
 * 
 */
$config->tableSalt = 'secret string'; 

如果你的英文没问题相信已经看明白了,这里再简单解释一下,最新版本中加入了$config->userAuthSalt$config->tableSalt两个参数,这两个参数的值在服务端做迁移的时候需要注意保持一致性,不可以修改,所以我们的解决方法就是将这里两个值统一即可

忘记密码的解决方法

在根目录下建立一个文件,然后输入以下内容(根据情况修改用户名、密码参数)

require "index.php";
$admin = $users->get('admin'); // or whatever your username is
$admin->setAndSave('pass', 'yo123456');
$session->redirect($config->urls->admin);

完成后访问即可。

Post Comment