1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-28 21:31:37 +08:00

Merge branch 'develop' into demo

This commit is contained in:
xiaochong0302 2020-09-22 08:35:42 +08:00
commit e22082f28f
14 changed files with 48 additions and 32 deletions

View File

@ -21,7 +21,7 @@ class CourseController extends Controller
['type' => CategoryModel::TYPE_COURSE]
);
return $this->response->redirect($location);
$this->response->redirect($location);
}
/**

View File

@ -21,7 +21,7 @@ class HelpController extends Controller
['type' => CategoryModel::TYPE_HELP]
);
return $this->response->redirect($location);
$this->response->redirect($location);
}
/**

View File

@ -3,7 +3,6 @@
namespace App\Http\Admin\Controllers;
use App\Http\Admin\Services\Session as SessionService;
use App\Http\Admin\Services\Setting as SettingService;
use App\Library\AppInfo as AppInfo;
use App\Traits\Auth as AuthTrait;
use App\Traits\Response as ResponseTrait;
@ -30,12 +29,15 @@ class SessionController extends \Phalcon\Mvc\Controller
$this->response->redirect(['for' => 'admin.index']);
}
$sessionService = new SessionService();
$captcha = $sessionService->getCaptchaSettings();
if ($this->request->isPost()) {
$this->checkHttpReferer();
$this->checkCsrfToken();
$sessionService = new SessionService();
$this->checkCsrfToken();
$sessionService->login();
@ -46,10 +48,6 @@ class SessionController extends \Phalcon\Mvc\Controller
$appInfo = new AppInfo();
$settingService = new SettingService();
$captcha = $settingService->getSettings('captcha');
$this->view->pick('public/login');
$this->view->setVar('app_info', $appInfo);
$this->view->setVar('captcha', $captcha);

View File

@ -23,7 +23,7 @@ class SettingController extends Controller
$data = $this->request->getPost();
$settingService->updateSectionSettings($section, $data);
$settingService->updateSettings($section, $data);
return $this->jsonSuccess(['msg' => '更新配置成功']);
@ -154,7 +154,7 @@ class SettingController extends Controller
$data = $this->request->getPost();
$settingService->updateSectionSettings($section, $data);
$settingService->updateSettings($section, $data);
return $this->jsonSuccess(['msg' => '更新配置成功']);
@ -206,7 +206,7 @@ class SettingController extends Controller
$data = $this->request->getPost();
$settingService->updateSectionSettings($section, $data);
$settingService->updateSettings($section, $data);
return $this->jsonSuccess(['msg' => '更新配置成功']);
@ -231,7 +231,7 @@ class SettingController extends Controller
$data = $this->request->getPost();
$settingService->updateSectionSettings($section, $data);
$settingService->updateSettings($section, $data);
$content = [
'location' => $this->request->getHTTPReferer(),
@ -284,7 +284,7 @@ class SettingController extends Controller
$data = $this->request->getPost();
$settingService->updateSectionSettings($section, $data);
$settingService->updateSettings($section, $data);
return $this->jsonSuccess(['msg' => '更新配置成功']);

View File

@ -146,7 +146,7 @@ class TestController extends Controller
$settingService = new SettingService();
$settingService->updateSectionSettings('captcha', ['enabled' => 1]);
$settingService->updateSettings('captcha', ['enabled' => 1]);
return $this->jsonSuccess(['msg' => '后台验证成功']);

View File

@ -55,7 +55,7 @@ class UserController extends Controller
$adminRole = $this->request->getPost('admin_role', 'int', 0);
if ($adminRole == RoleModel::ROLE_ROOT) {
return $this->response->redirect(['action' => 'list']);
$this->response->redirect(['action' => 'list']);
}
$userService = new UserService();
@ -84,7 +84,7 @@ class UserController extends Controller
$roles = $userService->getRoles();
if ($user->admin_role == RoleModel::ROLE_ROOT) {
return $this->response->redirect(['action' => 'list']);
$this->response->redirect(['action' => 'list']);
}
$this->view->setVar('user', $user);
@ -100,7 +100,7 @@ class UserController extends Controller
$adminRole = $this->request->getPost('admin_role', 'int', 0);
if ($adminRole == RoleModel::ROLE_ROOT) {
return $this->response->redirect(['action' => 'list']);
$this->response->redirect(['action' => 'list']);
}
$type = $this->request->getPost('type', 'string', 'user');

View File

@ -2,7 +2,8 @@
namespace App\Http\Admin\Services;
use App\Services\Auth as AuthService;
use App\Repos\Setting as SettingRepo;
use App\Services\Auth\Admin as AdminAuth;
use App\Validators\Account as AccountValidator;
use App\Validators\Captcha as CaptchaValidator;
@ -10,7 +11,7 @@ class Session extends Service
{
/**
* @var AuthService
* @var AdminAuth
*/
protected $auth;
@ -33,7 +34,7 @@ class Session extends Service
$user = $accountValidator->checkAdminLogin($post['account'], $post['password']);
$captchaSettings = $this->getSettings('captcha');
$captchaSettings = $this->getCaptchaSettings();
/**
* 验证码是一次性的,放到最后检查,减少第三方调用
@ -53,4 +54,21 @@ class Session extends Service
$this->auth->clearAuthInfo();
}
public function getCaptchaSettings()
{
$settingsRepo = new SettingRepo();
$items = $settingsRepo->findBySection('captcha');
$result = [];
if ($items->count() > 0) {
foreach ($items as $item) {
$result[$item->item_key] = $item->item_value;
}
}
return $result;
}
}

View File

@ -73,7 +73,7 @@ class Setting extends Service
return $result;
}
public function updateSectionSettings($section, $settings)
public function updateSettings($section, $settings)
{
$settingsRepo = new SettingRepo();
@ -98,12 +98,12 @@ class Setting extends Service
$settings['domain'] = str_replace($protocol, '', $settings['domain']);
}
$this->updateSectionSettings($section, $settings);
$this->updateSettings($section, $settings);
}
public function updateVodSettings($section, $settings)
{
$this->updateSectionSettings($section, $settings);
$this->updateSettings($section, $settings);
}
public function updateLiveSettings($section, $settings)
@ -116,14 +116,14 @@ class Setting extends Service
}
}
$this->updateSectionSettings($section, $settings);
$this->updateSettings($section, $settings);
}
public function updateSmsSettings($section, $settings)
{
$settings['template'] = kg_json_encode($settings['template']);
$this->updateSectionSettings($section, $settings);
$this->updateSettings($section, $settings);
}
public function updateVipSettings($items)

View File

@ -21,7 +21,7 @@ class AccountController extends Controller
public function registerAction()
{
if ($this->authUser->id > 0) {
return $this->response->redirect('/');
$this->response->redirect('/');
}
$service = new AccountService();

View File

@ -28,7 +28,7 @@ class ChapterController extends Controller
$owned = $chapter['me']['owned'] ?? false;
if (!$owned) {
return $this->response->redirect([
$this->response->redirect([
'for' => 'home.course.show',
'id' => $chapter['course']['id'],
]);

View File

@ -19,7 +19,7 @@ class ImController extends Controller
parent::initialize();
if ($this->authUser->id == 0) {
return $this->response->redirect(['for' => 'home.account.login']);
$this->response->redirect(['for' => 'home.account.login']);
}
}

View File

@ -24,7 +24,7 @@ class SearchController extends Controller
$type = $this->request->get('type', ['trim', 'string'], 'course');
if (empty($query)) {
return $this->response->redirect(['for' => 'home.course.list']);
$this->response->redirect(['for' => 'home.course.list']);
}
$this->seo->prependTitle(['搜索', $query]);

View File

@ -39,7 +39,7 @@ class TeacherController extends Controller
*/
public function showAction($id)
{
return $this->dispatcher->forward([
$this->dispatcher->forward([
'controller' => 'user',
'action' => 'show',
'params' => ['id' => $id],

View File

@ -38,7 +38,7 @@ class UserConsoleController extends Controller
*/
public function indexAction()
{
return $this->dispatcher->forward(['action' => 'courses']);
$this->dispatcher->forward(['action' => 'courses']);
}
/**