# AZ716: Signed in as someone else already

A transaction is one principal's. `authz.act_as()`, `authz.login_key()` and `authz.login_jwt()` refuse to sign in a transaction that is signed in as someone else already (nobody counts as someone else, once someone is signed in), or that views as someone or is limited by scopes (a key's, a token's), which a new sign-in would end. The first sign-in after `authz.act_as(NULL, NULL)` is fine, and so is the same principal again. The usual cause is code that signs in a transaction it didn't begin: a transaction of one request reused for another person, a job's work joined to a request's. Begin a transaction of its own for each principal. A test's transaction that acts for one person, then another (rolled back at the end), calls `authz.sign_out()` first, as the SDKs' test modes do. The policy's owner and superusers say who is signed in by hand, and aren't held to it. SQLSTATE 28000. It is a bug in the app: the SDKs leave it an error, a 500.

Reported to the app, by the `authz.*` functions and the policy's rules: the code is in the error's HINT (`rowstile help AZ716`), and the SDKs' errors carry it as `code`.
