Skip to content
Snippets Groups Projects
Commit 5f12340d authored by xamgore's avatar xamgore
Browse files

Code format

parent b1b3a6c2
Branches
No related merge requests found
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Authentication extends Controller {
public function before() {
parent::before();
if(UTF8::strcasecmp($this->request->action(), 'logout')) {
$user = User::instance();
if($user->isSignedIn()) {
$request = $user->Type . '/index';
$page = Request::factory($request)->execute();
$this->response->body($page);
}
class Controller_Authentication extends Controller
{
public function before() {
parent::before();
if (UTF8::strcasecmp($this->request->action(), 'logout')) {
$user = User::instance();
if ($user->isSignedIn()) {
$request = $user->Type . '/index';
$page = Request::factory($request)->execute();
$this->response->body($page);
}
}
}
private function sign()
{
if(!User::instance()->isSignedIn())
{
$type = $this->request->param('type');
$type = empty($type)? 'in': $type;
$twig = Twig::factory('sign/'.$type);
$twig->Markdown = new Parsedown();
$twig->Updates = Model_System::getChangeLog();
$this->response->body($twig);
}
private function sign() {
if (!User::instance()->isSignedIn()) {
$type = $this->request->param('type');
$type = empty($type) ? 'in' : $type;
$twig = Twig::factory('sign/' . $type);
$twig->Markdown = new Parsedown();
$twig->Updates = Model_System::getChangeLog();
$this->response->body($twig);
}
}
public function action_enter_backdoor()
{
$this->sign();
public function action_enter_backdoor() {
$this->sign();
}
public function action_enter_frontdoor() {
$admission = true;
$user = User::instance();
$role = $user->RoleMark;
$isNotSigned = !$user->isSignedIn();
$isNotAdmin = !Access::instance($role)->isAdmin();
if ($isNotSigned || $isNotAdmin) {
$admission = !$this->check_maintenance();
}
public function action_enter_frontdoor()
{
$admission = true;
$user = User::instance();
$role = $user->RoleMark;
$isNotSigned = !$user->isSignedIn();
$isNotAdmin = !Access::instance($role)->isAdmin();
if ($admission) {
$this->sign();
} else
$user->signOut();
}
if($isNotSigned || $isNotAdmin) {
$admission = !$this->check_maintenance();
}
public function action_remind() {
if (!User::instance()->isSignedIn()) {
$twig = Twig::factory('sign/remindpass');
if ($admission) {
$this->sign();
} else
$user->signOut();
$twig->Markdown = new Parsedown();
$twig->Updates = Model_System::getChangeLog();
$this->response->body($twig);
}
}
public function action_remind()
{
if(!User::instance()->isSignedIn())
{
$twig = Twig::factory('sign/remindpass');
public function action_endremind() {
$token = $this->request->param('token');
$twig->Markdown = new Parsedown();
$twig->Updates = Model_System::getChangeLog();
$this->response->body($twig);
}
if (!Account::instance()->checkToken($token)) {
$message = "Данная ссылка для восстановления пароля более не действительна!\n" .
"Либо истекло время действия ссылки, либо она уже была использована.";
throw HTTP_Exception::factory(403, $message);
}
public function action_endremind()
{
$token = $this->request->param('token');
if (!Account::instance()->checkToken($token)) {
$message = "Данная ссылка для восстановления пароля более не действительна!\n" .
"Либо истекло время действия ссылки, либо она уже была использована.";
throw HTTP_Exception::factory(403, $message);
}
if (!User::instance()->isSignedIn()) {
$twig = Twig::factory('sign/changepass');
if (!User::instance()->isSignedIn()) {
$twig = Twig::factory('sign/changepass');
$twig->Markdown = new Parsedown();
$twig->Updates = Model_System::getChangeLog();
$twig->Markdown = new Parsedown();
$twig->Updates = Model_System::getChangeLog();
$twig->Token = $token;
$this->response->body($twig);
}
}
public function action_logout()
{
User::instance()->signOut();
$this->redirect('sign', 302);
$twig->Token = $token;
$this->response->body($twig);
}
}
private function check_maintenance()
{
$maintenance_info = Model_Account::getMaintenanceInfo();
if ($maintenance_info['active']) {
$this->response->status(503);
$twig = Twig::factory('errors/http');
$twig->title = 'Закрыто на техобслуживание!';
$twig->code = 503;
$twig->message = "Восстановление работы сервиса: " . $maintenance_info['return'];
$this->response->body($twig);
return true;
}
else
return false;
}
public function action_logout() {
User::instance()->signOut();
$this->redirect('sign', 302);
}
public function action_check_maintenance()
{
$this->check_maintenance();
}
private function check_maintenance() {
$maintenance_info = Model_Account::getMaintenanceInfo();
if ($maintenance_info['active']) {
$this->response->status(503);
$twig = Twig::factory('errors/http');
$twig->title = 'Закрыто на техобслуживание!';
$twig->code = 503;
$twig->message = "Восстановление работы сервиса: " . $maintenance_info['return'];
$this->response->body($twig);
return true;
} else
return false;
}
public function action_check_maintenance() {
$this->check_maintenance();
}
} // End Welcome
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment