---
title: "AuthService"
generated: true
---
<GenerationInfo sourceFile="packages/core/src/service/services/auth.service.ts" sourceLine="37" packageName="@vendure/core" />

Contains methods relating to <DocsLink href="/reference/typescript-api/entities/session#session">Session</DocsLink>, <DocsLink href="/reference/typescript-api/entities/authenticated-session#authenticatedsession">AuthenticatedSession</DocsLink> & <DocsLink href="/reference/typescript-api/entities/anonymous-session#anonymoussession">AnonymousSession</DocsLink> entities.

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

<div className="members-wrapper">

### constructor

<MemberInfo kind="method" type={`(connection: <a href='/reference/typescript-api/data-access/transactional-connection#transactionalconnection'>TransactionalConnection</a>, configService: ConfigService, sessionService: <a href='/reference/typescript-api/services/session-service#sessionservice'>SessionService</a>, eventBus: <a href='/reference/typescript-api/events/event-bus#eventbus'>EventBus</a>) => AuthService`}   />


### authenticate

<MemberInfo kind="method" type={`(ctx: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, apiType: <a href='/reference/typescript-api/request/api-type#apitype'>ApiType</a>, authenticationMethod: string, authenticationData: any) => Promise<<a href='/reference/typescript-api/entities/authenticated-session#authenticatedsession'>AuthenticatedSession</a> | InvalidCredentialsError | NotVerifiedError>`}   />

Authenticates a user's credentials and if okay, creates a new <DocsLink href="/reference/typescript-api/entities/authenticated-session#authenticatedsession">AuthenticatedSession</DocsLink>.
### createAuthenticatedSessionForUser

<MemberInfo kind="method" type={`(ctx: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, user: <a href='/reference/typescript-api/entities/user#user'>User</a>, authenticationStrategyName: string) => Promise<<a href='/reference/typescript-api/entities/authenticated-session#authenticatedsession'>AuthenticatedSession</a> | NotVerifiedError>`}   />


### verifyUserPassword

<MemberInfo kind="method" type={`(ctx: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, userId: <a href='/reference/typescript-api/common/id#id'>ID</a>, password: string) => Promise<boolean | InvalidCredentialsError | ShopInvalidCredentialsError>`}   />

Verify the provided password against the one we have for the given user. Requires
the <DocsLink href="/reference/typescript-api/auth/native-authentication-strategy#nativeauthenticationstrategy">NativeAuthenticationStrategy</DocsLink> to be configured.
### destroyAuthenticatedSession

<MemberInfo kind="method" type={`(ctx: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, sessionToken: string) => Promise<void>`}   />

Deletes all sessions for the user associated with the given session token.


</div>
