🚨 Announcing Vendure v2 Beta

AuthService

AuthService

Contains methods relating to Session, AuthenticatedSession & AnonymousSession entities.

Signature

class AuthService {
  constructor(connection: TransactionalConnection, configService: ConfigService, sessionService: SessionService, eventBus: EventBus)
  async authenticate(ctx: RequestContext, apiType: ApiType, authenticationMethod: string, authenticationData: any) => Promise<AuthenticatedSession | InvalidCredentialsError | NotVerifiedError>;
  async createAuthenticatedSessionForUser(ctx: RequestContext, user: User, authenticationStrategyName: string) => Promise<AuthenticatedSession | NotVerifiedError>;
  async verifyUserPassword(ctx: RequestContext, userId: ID, password: string) => Promise<boolean | InvalidCredentialsError | ShopInvalidCredentialsError>;
  async destroyAuthenticatedSession(ctx: RequestContext, sessionToken: string) => Promise<void>;
}

Members

constructor

method
type:
(connection: TransactionalConnection, configService: ConfigService, sessionService: SessionService, eventBus: EventBus) => AuthService

authenticate

async method
type:
(ctx: RequestContext, apiType: ApiType, authenticationMethod: string, authenticationData: any) => Promise<AuthenticatedSession | InvalidCredentialsError | NotVerifiedError>
Authenticates a user’s credentials and if okay, creates a new AuthenticatedSession.

createAuthenticatedSessionForUser

async method
type:
(ctx: RequestContext, user: User, authenticationStrategyName: string) => Promise<AuthenticatedSession | NotVerifiedError>

verifyUserPassword

async method
type:
(ctx: RequestContext, userId: ID, password: string) => Promise<boolean | InvalidCredentialsError | ShopInvalidCredentialsError>
Verify the provided password against the one we have for the given user. Requires the NativeAuthenticationStrategy to be configured.

destroyAuthenticatedSession

async method
type:
(ctx: RequestContext, sessionToken: string) => Promise<void>
Deletes all sessions for the user associated with the given session token.