/**
  * Check the login data
  *
  * Determines if the login data is valid. If so, logs the user
  * in, and redirects to the 'with friends' page, or to the stored
  * return-to URL.
  *
  * @return void
  */
 protected function handlePost()
 {
     parent::handlePost();
     // XXX: login throttle
     $nickname = $this->trimmed('nickname');
     $password = $this->arg('password');
     $user = common_check_user($nickname, $password);
     if (!$user instanceof User) {
         // TRANS: Form validation error displayed when trying to log in with incorrect credentials.
         throw new ServerException(_('Incorrect username or password.'));
     }
     // success!
     if (!common_set_user($user)) {
         // TRANS: Server error displayed when during login a server error occurs.
         throw new ServerException(_('Error setting user. You are probably not authorized.'));
     }
     common_real_login(true);
     $this->updateScopedProfile();
     if ($this->boolean('rememberme')) {
         common_rememberme($user);
     }
     $url = common_get_returnto();
     if ($url) {
         // We don't have to return to it again
         common_set_returnto(null);
         $url = common_inject_session($url);
     } else {
         $url = common_local_url('all', array('nickname' => $this->scoped->nickname));
     }
     common_redirect($url, 303);
 }