phacility/phabricator · error · Exception

You can not sign a document on behalf of a corporation unles

Error message

You can not sign a document on behalf of a corporation unless you are logged in.

What it means

LegalpadDocumentSignController::readCorporateSignatureForm() records which user signed on the corporation's behalf, so it requires an authenticated viewer and throws immediately when $viewer->isLoggedIn() is false. Anonymous visitors can sign documents individually, but the corporation flow has no anonymous path.

Source

Thrown at src/applications/legalpad/controller/LegalpadDocumentSignController.php:608

          $field_errors['email'] = pht('Invalid');
          $errors[] = pht('A valid email is required.');
        } else {
          $field_errors['email'] = null;
        }
      }
    }
    $signature_data['email'] = $email;

    return array($signature_data, $errors, $field_errors);
  }

  private function readCorporateSignatureForm(
    LegalpadDocument $document,
    AphrontRequest $request) {

    $viewer = $request->getUser();
    if (!$viewer->isLoggedIn()) {
      throw new Exception(
        pht(
          'You can not sign a document on behalf of a corporation unless '.
          'you are logged in.'));
    }

    $signature_data = array();
    $errors = array();
    $field_errors = array();

    $name = $request->getStr('name');

    if (!strlen($name)) {
      $field_errors['name'] = pht('Required');
      $errors[] = pht('Company name is required.');
    } else {
      $field_errors['name'] = null;
    }
    $signature_data['name'] = $name;

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Log in (or restore the session) and submit the corporate signature again.
  2. If scripting, authenticate first or use Conduit/CLI paths that operate as a real user.
  3. In custom controllers, gate the corporate flow on $viewer->isLoggedIn() before rendering the form (see exampleFix).

Example fix

// before
$signature_data = $this->readCorporateSignatureForm($document, $request);
// after
if ($viewer->isLoggedIn()) {
  $signature_data = $this->readCorporateSignatureForm($document, $request);
} else {
  return $this->newDialog()
    ->setTitle(pht('Log In Required'))
    ->appendParagraph(pht('Corporate signatures require a logged-in account.'))
    ->addCancelButton('/login/');
}
Defensive patterns

Strategy: validation

Validate before calling

// Gate corporate signing before reading the form:
$viewer = $request->getUser();
if (!$viewer->isLoggedIn()) {
  return id(new Aphront404Response()); // or redirect to /login/
}
$signature_data = $this->readCorporateSignatureForm($document, $request);

Prevention

When it happens

Trigger: A POST to the legalpad document sign endpoint with signatureType=corporation from a logged-out session -- curl, an expired session mid-form, or a scripted client that never authenticates.

Common situations: Session expiring while a long corporate-signing form was being filled; custom integrations hitting the sign controller without a logged-in cookie; UI flow bugs that render the corporate form to anonymous users.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/55e227a57e4d3ce5. Report an issue: GitHub.