Skip to content

Expose WebContainer.authorizeEndpoint #359

Description

@kiootic

In React Router, a common pattern for protected route is like this:

async function protectedRouteLoader(request) {
  const user = await checkAuthenticatedUser(request);
  if (user == null) {
    return redirect(LOGIN_URI);
  }
  const data = await loadRouteData(request, user);
  return data;
}
const route = {
  loader: protectedRouteLoader,
  Component: DataViewComponent,
};

Currently (@authgear/web@2.15.0) the container only exposes startAuthentication, which internally calls authorizeEndpoint and redirect directly by setting location.href. Ideally we could call authorizeEndpoint directly and do redirect(await container.authorizeEndpoint()). A workaround is to call startAuthentication and await forever, but it would not work if a server-side framework is involved.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions