优化后台秘密修改,前台文章评论状态判断
This commit is contained in:
parent
1bb5c995cf
commit
b9766d0c7b
@ -3,8 +3,8 @@
|
||||
> TaoLer是一个简单迅捷的轻论坛系统,适用于个人或组织区域型信息交流发布平台。
|
||||
|
||||
* 官网:https://www.aieok.com
|
||||
* 版本:TaoLer 1.8.16
|
||||
* 日期:2021.12.21
|
||||
* 版本:TaoLer 1.8.17
|
||||
* 日期:2021.12.25
|
||||
|
||||
webman版新架构已适配90%
|
||||
|
||||
|
BIN
addons/gitee - 快捷方式.lnk
Normal file
BIN
addons/gitee - 快捷方式.lnk
Normal file
Binary file not shown.
@ -176,34 +176,18 @@ class Admin extends AdminController
|
||||
return View::fetch('set/user/repass');
|
||||
}
|
||||
|
||||
//密码重设
|
||||
public function repassSet()
|
||||
{
|
||||
$admin = AdminModel::find(Session::get('admin_id'));
|
||||
if(Request::isAjax()){
|
||||
$data = Request::param();
|
||||
$salt = substr(md5(strtotime($admin['create_time'])),-6);
|
||||
$pwd = substr_replace(md5($data['oldPassword']),$salt,0,6);
|
||||
$data['oldPassword'] = md5($pwd);
|
||||
if($admin['password'] != $data['oldPassword']){
|
||||
return json(['code'=>-1,'msg'=>'当前密码错误']);
|
||||
} elseif($data['password'] != $data['repassword']){
|
||||
return json(['code'=>-1,'msg'=>'两次密码不一致']);
|
||||
} else {
|
||||
$password = md5(substr_replace(md5($data['password']),$salt,0,6));
|
||||
$result = $admin->update([
|
||||
'id' => $admin['id'],
|
||||
'password' => $password
|
||||
]);
|
||||
if($result){
|
||||
$res = ['code'=>0,'msg'=>'更新成功'];
|
||||
} else {
|
||||
$res = ['code'=>-1,'msg'=>'更新失败'];
|
||||
}
|
||||
return json($res);
|
||||
}
|
||||
//修改密码
|
||||
public function repassSet()
|
||||
{
|
||||
if(Request::isAjax()){
|
||||
$data = Request::only(['oldPassword','password','repassword']);
|
||||
$data['admin_id'] = $this->aid;
|
||||
|
||||
$admin = new AdminModel;
|
||||
$res = $admin->setpass($data);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//清除缓存Cache
|
||||
public function clearCache(){
|
||||
|
@ -16,6 +16,12 @@ class Admin extends Model
|
||||
use SoftDelete;
|
||||
protected $deleteTime = 'delete_time';
|
||||
protected $defaultSoftDelete = 0;
|
||||
protected $createTime = 'false';
|
||||
|
||||
//自动对password进行md5加密
|
||||
protected function setPasswordAttr($value){
|
||||
return md5($value);
|
||||
}
|
||||
|
||||
//管理员关联角色
|
||||
/*
|
||||
@ -45,17 +51,19 @@ class Admin extends Model
|
||||
public function login($data)
|
||||
{
|
||||
//查询用户
|
||||
$admin = Db::name('admin')->where('username',$data['username'])->where('delete_time',0)->find();
|
||||
$admin = $this->where('username',$data['username'])->where('delete_time',0)->find();
|
||||
|
||||
if(is_null($admin)){
|
||||
return '用户名或密码错误';
|
||||
return json(['code'=>-1,'msg'=>'用户名或密码错误']);
|
||||
}
|
||||
if($admin['status'] !=1){
|
||||
return '用户被禁用或未审核,请联系管理员';
|
||||
return json(['code' => -1,'msg'=> '用户被禁用或未审核,请联系管理员']);
|
||||
}
|
||||
//对输入的密码字段进行MD5加密,再进行数据库的查询
|
||||
$salt = substr(md5($admin['create_time']),-6);
|
||||
$pwd = substr_replace(md5($data['password']),$salt,0,6);
|
||||
$data['password'] = md5($pwd);
|
||||
|
||||
if($admin['password'] == $data['password']){
|
||||
|
||||
//将用户数据写入Session
|
||||
@ -77,9 +85,45 @@ class Admin extends Model
|
||||
);
|
||||
|
||||
//用户名密码正确返回1
|
||||
return 1;
|
||||
$res = ['code'=>0,'msg'=>'登陆成功', 'url'=>(string) url('index/index')];
|
||||
} else {
|
||||
return "用户名或密码错误!";
|
||||
$res = ['code'=>-1,'msg'=>'用户名或密码错误','url'=>(string) url('admin/login')];
|
||||
}
|
||||
return json($res);
|
||||
}
|
||||
|
||||
//修改密码
|
||||
public function setpass($data)
|
||||
{
|
||||
$admin = $this->find($data['admin_id']);
|
||||
$salt = substr(md5($admin['create_time']),-6);
|
||||
$oldPassword = $this->pass($salt,$data['oldPassword']);
|
||||
if($oldPassword != $admin['password']){
|
||||
return json(['code'=>-1,'msg'=>'当前密码错误']);
|
||||
}
|
||||
|
||||
if($data['password'] != $data['repassword']){
|
||||
return json(['code'=>-1,'msg'=>'两次密码不一致']);
|
||||
}
|
||||
|
||||
$data['password'] = substr_replace(md5($data['password']),$salt,0,6);
|
||||
$admin->password = $data['password'];
|
||||
$result = $admin->save();
|
||||
|
||||
if($result){
|
||||
$res = ['code'=>0,'msg'=>'修改密码成功'];
|
||||
} else {
|
||||
$res = ['code'=>-1,'msg'=>'修改密码失败'];
|
||||
}
|
||||
|
||||
return json($res);
|
||||
}
|
||||
|
||||
//加密规则 加密字符串,原始秘密
|
||||
protected function pass($salt, $pass)
|
||||
{
|
||||
$pwd = substr_replace(md5($pass),$salt,0,6);
|
||||
return md5($pwd);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -155,6 +155,7 @@ class User extends Model
|
||||
$user = $this->find($data['user_id']);
|
||||
$salt = substr(md5($user['create_time']),-6);
|
||||
$pwd = substr_replace(md5($data['nowpass']),$salt,0,6);
|
||||
//原注册密码加密规则
|
||||
$data['nowpass'] = md5($pwd);
|
||||
$result = $data['nowpass'] == $user['password'];
|
||||
if(!$result){
|
||||
|
@ -84,12 +84,12 @@ class Article extends BaseController
|
||||
$page = input('page') ? input('page') : 1;
|
||||
$article = new ArticleModel();
|
||||
$artDetail = $article->getArtDetail($id);
|
||||
$arId = $artDetail->cate->id;
|
||||
$tpl = Db::name('cate')->where('id',$arId)->value('detpl');
|
||||
if(!$artDetail){
|
||||
if(is_null($artDetail)){
|
||||
// 抛出 HTTP 异常
|
||||
throw new \think\exception\HttpException(404, '异常消息');
|
||||
}
|
||||
$arId = $artDetail->cate->id;
|
||||
$tpl = Db::name('cate')->where('id',$arId)->value('detpl');
|
||||
$comments = $artDetail->comments()->where('status',1)->order(['cai'=>'asc','create_time'=>'asc'])->paginate(['list_rows'=>10, 'page'=>$page]);
|
||||
//$comment = new \app\common\model\Comment();
|
||||
//$comments = $comment->getComment($id);
|
||||
@ -119,6 +119,10 @@ class Article extends BaseController
|
||||
//获取评论
|
||||
$data = Request::only(['content','article_id','user_id']);
|
||||
$sendId = $data['user_id'];
|
||||
$art = Db::name('article')->field('id,status,is_reply,delete_time')->find($data['article_id']);
|
||||
if($art['delete_time'] != 0 || $art['status'] != 1 || $art['is_reply'] != 1){
|
||||
return json(['code'=>-1, 'msg'=>'评论不可用状态']);
|
||||
}
|
||||
if(empty($data['content'])){
|
||||
return json(['code'=>0, 'msg'=>'评论不能为空!']);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ return [
|
||||
//应用名,此项不可更改
|
||||
'appname' => 'TaoLer',
|
||||
//版本配置
|
||||
'version' => '1.8.15',
|
||||
'version' => '1.8.17',
|
||||
//加盐
|
||||
'salt' => 'taoler',
|
||||
//数据库备份目录
|
||||
|
2
view/taoler/index/public/.gitignore
vendored
2
view/taoler/index/public/.gitignore
vendored
@ -1 +1 @@
|
||||
user-nav.html
|
||||
!.gitignore
|
||||
|
@ -23,12 +23,6 @@
|
||||
{:lang('my message')}
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-nav-item {if($Request.action=='key')}layui-this{/if}">
|
||||
<a href="{:url('Api/key')}">
|
||||
<i class="layui-icon layui-icon-vercode"></i>
|
||||
{:lang('my auth')}
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-nav-item">
|
||||
<a href="{:url('user/home',['id'=>session('user_id')])}">
|
||||
<i class="layui-icon layui-icon-home"></i>
|
||||
|
Loading…
Reference in New Issue
Block a user