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.

User|null
findUserToLink(string $provider, string $identifier, array $provided)

Find an existing account to link this provider identity to, when it has no link yet. By default that is the account with the email address the provider vouched for ({Registration::provideTrustedEmail()}).

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

Find an existing account to link this provider identity to, when it has no link yet. By default that is the account with the email address the provider vouched for ({Registration::provideTrustedEmail()}).

Override this to change which account is linked. Returning null sends the user to sign up, where an address already in use is rejected until 3.0 makes email addresses non-unique (flarum/framework#4426).

Parameters

string $provider
string $identifier
array $provided

Return Value

User|null

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