getDeploySessionUserinfo method

Future<SessionUser?> getDeploySessionUserinfo()

Answers "is this browser signed in, and if not where does it sign in?" — the dashboard SPA's bootstrap question, and the only route on this plane that answers for an anonymous caller.

Answers "is this browser signed in, and if not where does it sign in?" — the dashboard SPA's bootstrap question, and the only route on this plane that answers for an anonymous caller. The anonymous answer carries loggedIn:false and a URL and NOTHING else: no username, no org, no groups, no issuer, no hint about who the caller might be or what exists in the cluster. Answering it costs nothing (the caller already knows whether it holds a cookie) and withholding it costs the whole sign-in journey. The predicate is the platform SuperAdmin fact — the SAME one every other route here gates on, minted from a validated principal whose org is the reserved admin org — so a validated-but-not-SuperAdmin caller is reported as NOT signed in, which is the truth as this console defines it: they cannot use it.

Implementation

Future<SessionUser?> getDeploySessionUserinfo() async {
  final response = await getDeploySessionUserinfoWithHttpInfo();
  if (response.statusCode >= HttpStatus.badRequest) {
    throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
    return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'SessionUser',) as SessionUser;

  }
  return null;
}