初始化
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
// 注意:旧版 auth.php 已被弃用
|
||||
// 新版应用使用 app/controllers 中的 Controller::checkLogin() 和 requireAdminRole() 进行鉴权
|
||||
// 此文件保留仅为兼容,实际不会执行(因为 public/ 目录已移除)
|
||||
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['user_id']) && !isset($_SESSION['user'])) {
|
||||
header("Location: /Login/index");
|
||||
exit;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 密码哈希函数(使用 bcrypt,兼容旧版 MD5)
|
||||
* @deprecated 请使用 app\models\Employee::hashPassword()
|
||||
*/
|
||||
function md5_pwd($pwd) {
|
||||
return password_hash($pwd, PASSWORD_BCRYPT, ['cost' => 12]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证密码(兼容旧版 MD5)
|
||||
* @deprecated 请使用 app\models\Employee::validateLogin()
|
||||
*/
|
||||
function verify_pwd($pwd, $hash) {
|
||||
// 判断是否为 bcrypt(bcrypt 哈希以 $2y$ 开头)
|
||||
if (substr($hash, 0, 4) === '$2y$') {
|
||||
return password_verify($pwd, $hash);
|
||||
}
|
||||
// 兼容旧版 MD5
|
||||
return md5($pwd) === $hash;
|
||||
}
|
||||
Reference in New Issue
Block a user