<?php<364666827@qq.com>,开发者QQ群:50304283
namespace app\system\admin;
use app\common\controller\Common;
use app\system\model\SystemUser as UserModel;
class Publics extends Common
{
/**
* 登陆页面
* @author 橘子俊 <364666827@qq.com>
* @return mixed
*/
public function index()
{
$model = new UserModel;
if ($this->request->isPost()) {
$username = $this->request->post('username/s');
$password = $this->request->post('password/s');
if (!$model->login($username, $password)) {
$data = [];
$data['token'] = $this->request->token();
return $this->error($model->getError(), url('index'), $data);
}
return $this->success('登陆成功,页面跳转中...', url('index/index'));
}
if ($model->isLogin()) {
$this->redirect(url('index/index', '', true, true));
}
$this->view->engine->layout(false);
return $this->fetch();
}
/**
* 退出登陆
* @author 橘子俊 <364666827@qq.com>
* @return mixed
*/
public function logout(){
model('SystemUser')->logout();
$this->redirect(ROOT_DIR);
}
/**
* 图标选择
* @author 橘子俊 <364666827@qq.com>
* @return mixed
*/
public function icon() {
return $this->fetch();
}
/**
* 解锁屏幕
* @author 橘子俊 <364666827@qq.com>
* @return mixed
*/
public function unlocked()
{
$_pwd = $this->request->post('password/s');
$model = model('SystemUser');
$login = $model->isLogin();
if (!$login) {
return $this->error('登录信息失效,请重新登录!');
}
$password = $model->where('id', $login['uid'])->value('password');
if (!$password) {
return $this->error('登录异常,请重新登录!');
}
if (!password_verify($_pwd, $password)) {
return $this->error('密码错误,请重新输入!');
}
return $this->success('解锁成功');
}
}