Standard\Controllers\AuthController::processSignupAction PHP Метод

processSignupAction() публичный Метод

public processSignupAction ( )
    public function processSignupAction()
    {
        try {
            v::email()->check($_POST['email']);
            v::length(6)->check($_POST['password']);
        } catch (ValidationException $e) {
            $this->flasher->error('Please make sure your password is longer than 6 characters, and that your username is a valid email address!');
        }
        if ($_POST['password'] !== $_POST['password_confirm']) {
            $this->flasher->error('Passwords need to be identical');
        }
        if ($this->flasher->hasMessages('error')) {
            $this->redirect('/auth');
        }
        $this->initGroups();
        // Create an account if none exists
        $user = Gatekeeper::register(['first_name' => '-', 'last_name' => '-', 'username' => $_POST['email'], 'email' => $_POST['email'], 'password' => $_POST['password'], 'groups' => Gatekeeper::countUser() ? ['users'] : ['admin', 'users']]);
        if ($user) {
            $this->flasher->success('Account successfully registered! Please log in!');
        } else {
            $this->flasher->error('Error #GK01: Account creation failed!' . Gatekeeper::getDatasource()->getLastError());
        }
        $this->redirect('/auth');
    }