@@ -24,6 +24,7 @@ import {
2424 verifyJwt as verifyServiceJwt ,
2525} from '@atproto/xrpc-server'
2626import { AccountManager } from './account-manager/account-manager'
27+ import { ActorAccount } from './account-manager/helpers/account'
2728import {
2829 AccessOutput ,
2930 AdminTokenOutput ,
@@ -424,30 +425,43 @@ export class AuthVerifier {
424425
425426 protected async verifyStatus (
426427 did : string ,
427- { checkTakedown = false , checkDeactivated = false } : VerifiedOptions ,
428+ options : VerifiedOptions ,
428429 ) : Promise < void > {
429- if ( checkTakedown || checkDeactivated ) {
430- const found = await this . accountManager . getAccount ( did , {
431- includeDeactivated : true ,
432- includeTakenDown : true ,
433- } )
434- if ( ! found ) {
435- // will be turned into ExpiredToken for the client if proxied by entryway
436- throw new ForbiddenError ( 'Account not found' , 'AccountNotFound' )
437- }
438- if ( checkTakedown && softDeleted ( found ) ) {
439- throw new AuthRequiredError (
440- 'Account has been taken down' ,
441- 'AccountTakedown' ,
442- )
443- }
444- if ( checkDeactivated && found . deactivatedAt ) {
445- throw new AuthRequiredError (
446- 'Account is deactivated' ,
447- 'AccountDeactivated' ,
448- )
449- }
430+ if ( options . checkDeactivated || options . checkTakedown ) {
431+ await this . findAccount ( did , options )
432+ }
433+ }
434+
435+ /**
436+ * Finds an account by its handle or DID, returning possibly deactivated or
437+ * taken down accounts (unless `options.checkDeactivated` or
438+ * `options.checkTakedown` are set to true, respectively).
439+ */
440+ public async findAccount (
441+ handleOrDid : string ,
442+ options : VerifiedOptions ,
443+ ) : Promise < ActorAccount > {
444+ const account = await this . accountManager . getAccount ( handleOrDid , {
445+ includeDeactivated : true ,
446+ includeTakenDown : true ,
447+ } )
448+ if ( ! account ) {
449+ // will be turned into ExpiredToken for the client if proxied by entryway
450+ throw new ForbiddenError ( 'Account not found' , 'AccountNotFound' )
451+ }
452+ if ( options . checkTakedown && softDeleted ( account ) ) {
453+ throw new AuthRequiredError (
454+ 'Account has been taken down' ,
455+ 'AccountTakedown' ,
456+ )
457+ }
458+ if ( options . checkDeactivated && account . deactivatedAt ) {
459+ throw new AuthRequiredError (
460+ 'Account is deactivated' ,
461+ 'AccountDeactivated' ,
462+ )
450463 }
464+ return account
451465 }
452466
453467 /**
0 commit comments