예제 #1
0
 /**
  * @param $parameters Parameters
  * @param $form       array
  * @param $files      array
  * @return mixed
  */
 public function run(Parameters $parameters, $form, $files)
 {
     $current = User::current();
     if ($current) {
         Authentication::disconnect(User::current());
     }
     $parameters = $this->getViewParameters($parameters, $form, User::class);
     if (isset($form['login']) && isset($form['password'])) {
         $user = null;
         $errors_messages = Authentication::controlRegisterFormParameters($form);
         if (!$errors_messages && empty($errors_messages)) {
             if (Authentication::controlNameNotUsed($form['login'])) {
                 $user = Authentication::register($form);
             }
         }
         if ($user) {
             $parameters[Template::TEMPLATE] = 'confirm';
             return View::run($parameters, $form, $files, User::class, 'register');
         } else {
             $parameters['errors'] = $errors_messages;
             $parameters[Template::TEMPLATE] = 'error';
             return View::run($parameters, $form, $files, User::class, 'register');
         }
     } else {
         $parameters['inputs'] = Authentication::getRegisterInputs();
         return View::run($parameters, $form, $files, User::class, 'register');
     }
 }
예제 #2
0
 /**
  * @param Parameters $parameters
  * @param array                 $form
  * @param array                 $files
  * @return mixed
  */
 public function run(Parameters $parameters, $form, $files)
 {
     $parameters = $parameters->getObjects();
     $current_user = User::current();
     if (!isset($current_user)) {
         $current_user = new User();
     }
     Authentication::disconnect($current_user);
     array_unshift($parameters, $current_user);
     session_destroy();
     return View::run($parameters, $form, $files, get_class($current_user), 'disconnect');
 }
예제 #3
0
 /**
  * @param $parameters Parameters
  * @param $form       string[] an authentication form result with keys 'login' and 'password'
  * @param $files      array
  * @return mixed
  */
 public function run(Parameters $parameters, $form, $files)
 {
     if (isset($form['login']) && isset($form['password'])) {
         $current = User::current();
         if ($current) {
             Authentication::disconnect(User::current());
         }
         $user = Authentication::login($form['login'], $form['password']);
         if (isset($user)) {
             Authentication::authenticate($user);
             return (new Default_Controller())->run($parameters, $form, $files, get_class($user), 'authenticate');
         }
     }
     return (new Default_Controller())->run($parameters, $form, $files, User::class, 'authenticateError');
 }
예제 #4
0
 /**
  * Run method for a feature controller working for any class
  *
  * @param $parameters Parameters
  * @param $form       array
  * @param $files      array
  * @param $class_name string
  * @return mixed
  */
 public function run(Parameters $parameters, $form, $files, $class_name)
 {
     if (isset($form['login']) && isset($form['password'])) {
         $current = User::current();
         if ($current) {
             Authentication::disconnect(User::current());
         }
         $user = Authentication::login($form['login'], $form['password']);
         if (isset($user)) {
             Authentication::authenticate($user);
             return self::AUTH_OK . rParse(Session::sid(), '=');
         }
     }
     return self::AUTH_ERROR;
 }