private function ProcessActions() { // Try to register try { // If user wants to register if ($this->registrationView->UserWantsToRegister()) { // Get Registration attempt $registrationAttemptArray = $this->registrationView->GetRegistrationAttempt(); // Create new userRegistration model from registration attempt $userRegistrationAttempt = new \model\UserRegistration($registrationAttemptArray['username'], $registrationAttemptArray['password'], $registrationAttemptArray['passwordRepeat']); // If there are no validation errors, proceed. if (\model\ValidationService::IsValid()) { // Create new user $newUser = new \model\User(null, $userRegistrationAttempt->GetUserName(), $userRegistrationAttempt->GetPassword()); // Add user in DAL $this->users->Add($newUser); // Set new message to display for user. \model\FlashMessageService::Set('Registered new user.'); // Store last login uname for login page $this->auth->SetLoginUsername($newUser); // New user registered successfully. Redirect to login page $this->appController->ReloadPage(); } } } catch (\Exception $exception) { // Store exceptions in applications exceptions container model \model\ExceptionsService::AddException($exception); } // Return registration failure return false; }
private function DoLoginSuccess($user) { // Store logged in user object in sessions cookie $this->auth->KeepUserLoggedInForSession($user); // Check if user wants login to be remembered if ($this->formView->DoesUserWantLoginToBeRemembered()) { // Save persistent login on server $this->auth->SaveLoginOnServer($user); // Save persistent login on client $this->formView->SaveLoginOnClient($user); } // Set a login message to be displayed for the user. \model\FlashMessageService::Set($this->formView->GetLoggedInMessage()); $this->appController->ReloadPage(); }