class ResponseFactory

Methods

__construct(Rememberer $rememberer)

No description

ResponseInterface
make(string $provider, string $identifier, callable $configureRegistration, string $returnTo = '/')

Handle an OAuth callback by logging in an existing user or beginning the registration flow for a new one.

ResponseInterface
makeLoggedInResponse(User $user, string $returnTo)

Build a redirect response for a successfully authenticated existing user.

ResponseInterface
makeRegistrationResponse(string $token, string $returnTo)

Build a redirect response that triggers the registration modal on the frontend.

Details

__construct(Rememberer $rememberer)

Parameters

Rememberer $rememberer

ResponseInterface make(string $provider, string $identifier, callable $configureRegistration, string $returnTo = '/')

Handle an OAuth callback by logging in an existing user or beginning the registration flow for a new one.

Parameters

string $provider The OAuth provider name (e.g. 'github').
string $identifier The provider's unique identifier for this user.
callable $configureRegistration Callback that populates a {\Flarum\Forum\Auth\Registration} instance with data from the provider (email, username, avatar, etc.).
string $returnTo Validated same-origin URL to redirect to after login. Must be validated by the caller before being passed here.

Return Value

ResponseInterface

protected ResponseInterface makeLoggedInResponse(User $user, string $returnTo)

Build a redirect response for a successfully authenticated existing user.

Sets the remember-me cookie so the session is established on the next request. Override this method to customise the login redirect or cookie behaviour.

Parameters

User $user
string $returnTo

Return Value

ResponseInterface

protected ResponseInterface makeRegistrationResponse(string $token, string $returnTo)

Build a redirect response that triggers the registration modal on the frontend.

The `_flarum_auth` query parameter carries the registration token. The frontend detects this parameter on boot, strips it from the URL, and opens the SignUpModal pre-populated with data from the provider. Override this method to customise how the registration handoff is communicated to the frontend.

Parameters

string $token
string $returnTo

Return Value

ResponseInterface