getAuthorizationPage method Null safety

  1. @Operation()
Future<Response> getAuthorizationPage(
  1. {@Bind("scope") String? scope}
)

Returns an HTML login form.

A client that wishes to authenticate with this server should direct the user to this page. The user will enter their username and password that is sent as a POST request to this same controller.

The 'client_id' must be a registered, valid client of this server. The client must also provide a state to this request and verify that the redirect contains the same value in its query string.

Implementation

@Operation.get()
Future<Response> getAuthorizationPage({
  /// A space-delimited list of access scopes to be requested by the form submission on the returned page.
  @Bind.query("scope") String? scope,
}) async {
  if (delegate == null) {
    return Response(405, {}, null);
  }

  if (responseType != "code" && responseType != "token") {
    return _unsupportedResponseTypeResponse;
  }

  if (responseType == "token" && !allowsImplicit) {
    return _unsupportedResponseTypeResponse;
  }

  final renderedPage = await delegate!
      .render(this, request!.raw.uri, responseType, clientID, state, scope);
  if (renderedPage == null) {
    return Response.notFound();
  }

  return Response.ok(renderedPage)..contentType = ContentType.html;
}