Initial import
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace app\controllers;
|
||||
|
||||
use app\services\Auth;
|
||||
use app\services\openid\OpenIdService;
|
||||
use yii\web\Controller;
|
||||
use app\services\Validate;
|
||||
use app\models\UserAdminGlobal;
|
||||
use app\models\UserPartner;
|
||||
|
||||
class PublicController extends BaseController
|
||||
{
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->redirect('public/partner-register-login');
|
||||
}
|
||||
|
||||
|
||||
public function actionAdminGlobalLogin()
|
||||
{
|
||||
|
||||
//echo password_hash('cmsadmin23', PASSWORD_DEFAULT);
|
||||
//exit;
|
||||
|
||||
if (Auth::userAdminGlobal())
|
||||
return $this->redirect('/admin-global/index/dashboard');
|
||||
|
||||
Validate::login(UserAdminGlobal::class, function ($user) {
|
||||
$default = '/admin-global/index/dashboard';
|
||||
if(!empty($_SESSION['admin-global-page'])) {
|
||||
$default = $_SESSION['admin-global-page'];
|
||||
unset($_SESSION['admin-global-page']);
|
||||
}
|
||||
Auth::userAdminGlobalLogin($user->id, $default);
|
||||
});
|
||||
|
||||
$this->userType = 'Глобален CMS администратор';
|
||||
$this->pageTitle = 'Вход - Глобален CMS администратор';
|
||||
$this->userTypeKey = 'admin-global';
|
||||
return $this->render('login', ['idServer' => false]);
|
||||
}
|
||||
|
||||
public function actionPartnerLogin()
|
||||
{
|
||||
$partner = Auth::userPartner();
|
||||
if ($partner) {
|
||||
return $this->redirect('/partner/index/dashboard');
|
||||
}
|
||||
Validate::login(UserPartner::class, function (UserPartner $user) {
|
||||
Auth::userPartnerLogin($user->id, '/partner/index/dashboard');
|
||||
});
|
||||
$this->userType = 'Организация (Партньор)';
|
||||
$this->userTypeKey = 'partner';
|
||||
$this->pageTitle = \Yii::t('cms', 'Вход - Организация');
|
||||
return $this->render('login', ['idServer' => true]);
|
||||
}
|
||||
|
||||
public function actionPartnerRegisterLogin() {
|
||||
|
||||
$partner = Auth::userPartner();
|
||||
if (!$partner) {
|
||||
if(!empty($_SESSION['id_token_hint'])) {
|
||||
unset($_SESSION['id_token_hint']);
|
||||
}
|
||||
(new OpenIdService())->authenticationServerCheckout();
|
||||
} else {
|
||||
return $this->redirect('/partner/index/dashboard');
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
public function actionAdminRegisterLogin() {
|
||||
|
||||
$admin = Auth::userAdminCms();
|
||||
if (!$admin) {
|
||||
if(!empty($_SESSION['id_token_hint'])) {
|
||||
unset($_SESSION['id_token_hint']);
|
||||
}
|
||||
(new OpenIdService())->authenticationServerCheckout(true);
|
||||
} else {
|
||||
return $this->redirect('/admin-global/index/dashboard');
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user