You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.9 KiB

<?php
namespace app\system\controller\admin;
use app\BaseController;
use app\system\logic\Login;
use app\system\model\SystemLoginer;
use think\facade\View;
class Index extends Base
{
/**
* 首页
*/
public function index()
{
$login_er = serializeMysql(session('login_er'),1);
View::assign('login_er', $login_er);
return View::fetch();
}
/**
* 退出登录
*/
public function logout()
{
$login_er = serializeMysql(session('login_er'),1);
if ($login_er) {
session('login_er',null);
// $redis->del('user_auth');
}
return redirect(url('Login/login'));
}
/**
* 修改密码 2017-10-15
*/
public function changepasswd()
{
$login_er = serializeMysql(session('login_er'),1);
if (request()->isPost()) {
$password = input('post.oldpasswd');
$data['password'] = input('post.newpasswd');
$repassword = input('post.confirmpasswd');
if($data['password'] == $password)
{
return sendErrorMessage(1,'新密码不能与旧密码相同');
}
if ($data['password'] !== $repassword) {
return sendErrorMessage(1,'您输入的新密码与确认密码不一致');
}
if (strlen($data['password']) < 6) {
return sendErrorMessage(1,'新密码的长度不能小于6位');
}
$Login = new Login();
$res = $Login->updateUserInfo($login_er['id'], $password, $data);
if($res < 0)
{
return sendErrorMessage(1,'修改密码失败');
}
return sendSuccessMessage([],'修改密码成功!');
} else {
View::assign('login_er', $login_er);
return View::fetch();
}
}
}