mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-24 18:30:18 +08:00
完成登录验证
This commit is contained in:
parent
92bea2a0d4
commit
7a48dad141
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
//配置文件
|
//配置文件
|
||||||
return [
|
return [
|
||||||
|
'auth_key' => 'mbvUenPqbpxT5WTAXXkFVPHF})0AOGfsMIN01XLu52SgS<R]DQDfj6TlThl897Qd',
|
||||||
];
|
];
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
*
|
* 用户登录类
|
||||||
* @since 2016-02-18
|
* @since 2016-02-18
|
||||||
* @author zhaoxiang <zhaoxiang051405@outlook.com>
|
* @author zhaoxiang <zhaoxiang051405@outlook.com>
|
||||||
*/
|
*/
|
||||||
@ -8,6 +8,7 @@
|
|||||||
namespace app\admin\controller;
|
namespace app\admin\controller;
|
||||||
|
|
||||||
|
|
||||||
|
use think\Db;
|
||||||
use think\Request;
|
use think\Request;
|
||||||
|
|
||||||
class User extends Base {
|
class User extends Base {
|
||||||
@ -17,13 +18,23 @@ class User extends Base {
|
|||||||
$username = $request->post('username');
|
$username = $request->post('username');
|
||||||
$password = $request->post('password');
|
$password = $request->post('password');
|
||||||
if( !$username || !$password ){
|
if( !$username || !$password ){
|
||||||
$this->error('缺少关键数据!');
|
return $this->error('缺少关键数据!');
|
||||||
}
|
}
|
||||||
if( $request->post('name') ){
|
$password = $this->getPwdHash($password);
|
||||||
|
$isOk = Db::table('users')->where(['username' => $username, 'password' => $password])->count();
|
||||||
|
if( !$isOk ){
|
||||||
|
$this->error('用户名或者密码错误!');
|
||||||
|
}else{
|
||||||
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
return $this->fetch();
|
return $this->fetch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getPwdHash( $pwd ){
|
||||||
|
$hashKey = config('auth_key');
|
||||||
|
$newPwd = $pwd.$hashKey;
|
||||||
|
return md5(sha1($newPwd).$hashKey);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user