Skip to content

Commit

Permalink
修复登录漏洞
Browse files Browse the repository at this point in the history
  • Loading branch information
helloxz committed Feb 16, 2022
1 parent 6d886fb commit cbd6aa0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion controller/admin.php
Expand Up @@ -139,7 +139,7 @@ function check_auth($user,$password){
//获取cookie
$cookie = $_COOKIE['key'];
//如果cookie的值和计算的key不一致,则没有权限
if( $cookie != $key ){
if( $cookie !== $key ){
$msg = "<h3>认证失败,请<a href = 'index.php?c=login'>重新登录</a>!</h3>";
require('templates/admin/403.php');
exit;
Expand Down
4 changes: 2 additions & 2 deletions controller/login.php
Expand Up @@ -11,7 +11,7 @@
$cookie = $_COOKIE['key'];

//如果已经登录,直接跳转
if( $cookie == $key ){
if( $cookie === $key ){
header('location:index.php?c=admin');
exit;
}
Expand All @@ -21,7 +21,7 @@
$user = $_POST['user'];
$pass = $_POST['password'];
header('Content-Type:application/json; charset=utf-8');
if( ($user == $username) && ($pass == $password) ) {
if( ($user === $username) && ($pass === $password) ) {
$key = md5($username.$password.'onenav');
setcookie("key", $key, time()+30 * 24 * 60 * 60,"/");
$data = [
Expand Down

0 comments on commit cbd6aa0

Please sign in to comment.