/** * Register page action * POST-request after form submit */ public function postRegister() { $this->app->log->debug(get_class($this) . '->postRegister()'); // clean the input $user_email = strip_tags($this->app->request->post('user_email')); $user_name = null; // strip_tags($this->app->request->post('user_name')); if (!$user_name) { // Se non specificato, utilizzo l'indirizzo email come username $user_name = $user_email; } $user_email_repeat = NULL; // potrei usare strip_tags($this->app->request->post('user_email_repeat')); $user_password_new = $this->app->request->post('user_password_new'); $user_password_repeat = $this->app->request->post('user_password_repeat'); $captcha = $this->app->request->post('g-recaptcha-response'); $redirect = ltrim(urldecode($this->app->request->post('redirect'))); $registration_successful = RegistrationModel::registerNewUser($user_name, $user_email, $user_email_repeat, $user_password_new, $user_password_repeat, $captcha, UserModel::PROVIDER_TYPE_DEFAULT); if ($registration_successful) { $login_successful = LoginModel::login($user_name, $user_password_new, true, UserModel::PROVIDER_TYPE_DEFAULT); $this->redirectAfterLogin($login_successful); } else { $app->redirect($app->config('app.baseurl') . '/register'); } }
/** * The login action, when you do login/login */ public function postLogin() { // Il metodo è utilizzato solo per il login con email $this->app->log->debug(get_class($this) . '->postLogin()'); // check if csrf token is valid $token = $this->app->request->post(Session::SESSION_CSRF_TOKEN); if (!Csrf::isTokenValid($token)) { LoginModel::logout(); $this->redirectHome(); exit; } // perform the login method, put result (true or false) into $login_successful $login_successful = LoginModel::login($this->app->request->post('user_name'), $this->app->request->post('user_password'), $this->app->request->post('set_remember_me_cookie'), UserModel::PROVIDER_TYPE_DEFAULT); // check login status: if true, then redirect user to user/index, if false, then to login form again $this->redirectAfterLogin($login_successful); }