完善演示模式下无法修改数据

This commit is contained in:
乐风 2021-04-02 17:45:43 +08:00
parent 0d8dea3c01
commit 2c35ffec4f
3 changed files with 25 additions and 14 deletions

View File

@ -6,7 +6,7 @@ use Request;
use App\Support\Totp; use App\Support\Totp;
use App\Support\Captcha; use App\Support\Captcha;
use App\Support\License;
use Gdoo\User\Models\UserLog; use Gdoo\User\Models\UserLog;
use Gdoo\User\Models\User; use Gdoo\User\Models\User;
@ -24,6 +24,9 @@ class AuthController extends Controller
*/ */
public function totp() public function totp()
{ {
// 关闭演示模式
License::demoClose();
// 时间验证密钥 // 时间验证密钥
$t = new Totp(); $t = new Totp();
$gets = Request::all(); $gets = Request::all();
@ -78,6 +81,10 @@ class AuthController extends Controller
$this->ret->set('show_captcha', $this->setting['login_captcha'] <= $log->error_count); $this->ret->set('show_captcha', $this->setting['login_captcha'] <= $log->error_count);
if (Request::method() == 'POST') { if (Request::method() == 'POST') {
// 关闭演示模式
License::demoClose();
if (empty($gets['username'])) { if (empty($gets['username'])) {
return $this->ret->error('用户名不能为空,请重新填写。'); return $this->ret->error('用户名不能为空,请重新填写。');
} }
@ -169,6 +176,9 @@ class AuthController extends Controller
*/ */
public function logout() public function logout()
{ {
// 关闭演示模式
License::demoClose();
Auth::logout(); Auth::logout();
Session::flush(); Session::flush();

View File

@ -18,7 +18,7 @@ class Builder extends BaseBuilder
public function insert(array $values) public function insert(array $values)
{ {
// 判断演示模式 // 判断演示模式
License::demoCheck($this->from); License::demoCheck();
$values = $this->checkColumnsValues($values); $values = $this->checkColumnsValues($values);
@ -40,7 +40,7 @@ class Builder extends BaseBuilder
public function insertGetId(array $values, $sequence = null) public function insertGetId(array $values, $sequence = null)
{ {
// 判断演示模式 // 判断演示模式
License::demoCheck($this->from); License::demoCheck();
$values = $this->checkColumnsValues($values); $values = $this->checkColumnsValues($values);
// 空数据 // 空数据
@ -60,7 +60,7 @@ class Builder extends BaseBuilder
public function update(array $values) public function update(array $values)
{ {
// 判断演示模式 // 判断演示模式
License::demoCheck($this->from); License::demoCheck();
$values = $this->checkColumnsValues($values, false); $values = $this->checkColumnsValues($values, false);
@ -81,7 +81,7 @@ class Builder extends BaseBuilder
public function delete($id = null) public function delete($id = null)
{ {
// 判断演示模式 // 判断演示模式
License::demoCheck($this->from); License::demoCheck();
return parent::delete($id); return parent::delete($id);
} }

View File

@ -28,18 +28,19 @@ class License
/** /**
* 判断是否演示模式 * 判断是否演示模式
*/ */
public static function demoCheck($table = null) public static function demoCheck()
{ {
if (env('DEMO_VERSION') == false) { if ($_ENV['DEMO_VERSION'] == false) {
return; return;
} }
$demoDatas = ['user','system_log'];
if (in_array($table, $demoDatas)) {
return;
}
abort_error('演示模式,不允许本操作。'); abort_error('演示模式,不允许本操作。');
} }
/**
* 关闭演示模式检查
*/
public static function demoClose()
{
$_ENV['DEMO_VERSION'] = false;
}
} }