Exemplo n.º 1
0
 public function index()
 {
     $auth = \Config\Auth::get_instance();
     $user = $auth->get_logged_user();
     if ($user) {
         header('Location: ' . DX_URL . 'admin/posts/index');
     }
     if (empty($user) && isset($_POST['username']) && isset($_POST['password']) && isset($_POST['passwordConfirmed']) && isset($_POST['email'])) {
         if ($_POST['password'] !== $_POST['passwordConfirmed']) {
             $this->registration_message = 'Passwords mismatch!';
         } else {
             $username = $_POST['username'];
             $password = $_POST['password'];
             $full_name = $_POST['fullName'];
             $email = $_POST['email'];
             $user = array('Username' => $username, 'Password' => $password, 'FullName' => $full_name, 'Email' => $email);
             $is_registered = $auth->register($user);
             if ($is_registered === self::register_not_possible) {
                 $this->registration_message = 'Register not successful. Try again!';
             } else {
                 $this->registration_message = 'Registration successful. Please login!';
                 $auth->login($username, $password);
                 header('Location: ' . DX_URL . 'admin/posts/index');
             }
         }
     }
     $template_name = DX_ROOT_DIR . $this->views_dir . 'index.php';
     include_once $this->layout;
 }
Exemplo n.º 2
0
 public function logout()
 {
     $auth = \Config\Auth::get_instance();
     $auth->logout();
     header('Location: ' . DX_URL . 'posts/index');
     //header( 'Location: ' . DX_URL . '?msg=' . urlencode( base64_encode( "You have been successfully logged out!" ) ) );
     //exit();
 }
Exemplo n.º 3
0
 public function __construct($class_name = '\\Admin\\Controllers\\Admin_Controller', $model = 'main', $views_dir = 'views/admin/main')
 {
     parent::__construct($class_name, $model, $views_dir);
     $logged_in = \Config\Auth::get_instance()->is_logged_in();
     if (!$logged_in) {
         header('Location: ' . DX_URL);
         exit;
     }
 }
Exemplo n.º 4
0
 public function __construct($class_name = '\\Controllers\\Main_Controller', $model = 'main', $views_dir = '/views/main/')
 {
     $this->views_dir = $views_dir;
     $this->class_name = $class_name;
     include_once DX_ROOT_DIR . "models/{$model}_model.php";
     $model_class = "\\Models\\" . ucfirst($model) . "_Model";
     $this->model = new $model_class(array('table' => 'none'));
     // \Models\Main_Model
     $auth = \Config\Auth::get_instance();
     $logged_user = $auth->get_logged_user();
     $this->logged_user = $logged_user;
     $this->layout = DX_ROOT_DIR . '/views/layouts/default.php';
 }