/**
  * A 'Welcome' screen for a new user
  */
 public function actionComplete()
 {
     $result = $this->accounts->getInvitedUser($invitationCode = $this->request->getPost('code'));
     if (empty($invitationCode) or empty($result)) {
         $this->renderAction('error');
     } else {
         $username = $this->request->getPost('username');
         $password1 = $this->request->getPost('password1');
         $password2 = $this->request->getPost('password2');
         // some fail conditions
         if (!$this->accounts->isUsernameUnique($username) or $password1 !== $password2) {
             $this->renderAction('error');
         }
         // set the new credentials
         try {
             $this->accounts->setInvitedUserCredentials($username, $password, $invitationCode);
         } catch (UserNotFoundException $e) {
             $this->renderAction('error');
         }
         // force authenticate the user
         $user = new User();
         $user->forceAuthenticate($username);
         $this->bag->account = $result;
         $this->renderAction();
     }
 }