Class Authenticator<User>

Create a new instance of the Authenticator.

It receives a instance of a Cookie created using Remix's createCookie.

It optionally receives an object with extra options. The supported options are:

let auth = new Authenticator();

Type Parameters

  • User = unknown

Constructors

Methods

Constructors

Methods

  • Call this to authenticate a request using some strategy. You pass the name of the strategy you want to use and the request to authenticate.

    Parameters

    Returns Promise<User>

    async function action({ request }: ActionFunctionArgs) {
    let user = await auth.authenticate("strategy-name", request);
    };
  • Call this method with the name of a strategy you want to get. It returns the Strategy instance or null if the strategy is not found.

    Parameters

    • name: string

    Returns null | Strategy<User, never>

  • Call this method with the name of the strategy you want to remove. It returns the Authenticator instance for concatenation.

    Parameters

    • name: string

    Returns Authenticator<unknown>

    auth.unuse("another").unuse("some");
    
  • Call this method with the Strategy, the optional name allows you to setup the same strategy multiple times with different names. It returns the Authenticator instance for concatenation.

    Parameters

    Returns Authenticator<User>

    auth.use(new SomeStrategy((user) => Promise.resolve(user)));
    auth.use(new SomeStrategy((user) => Promise.resolve(user)), "another");