enum PasswordLoginNextAction { redirectToOidc, acceptOidc, localLogin, invalid }

PasswordLoginNextAction decidePasswordLoginNextAction({
  required bool hasLoginChallenge,
  required String? redirectTo,
  required String? jwt,
}) {
  final hasRedirectTo = redirectTo != null && redirectTo.isNotEmpty;
  if (hasRedirectTo) {
    return PasswordLoginNextAction.redirectToOidc;
  }

  if (hasLoginChallenge) {
    return PasswordLoginNextAction.acceptOidc;
  }

  final hasJwt = jwt != null && jwt.isNotEmpty;
  if (hasJwt) {
    return PasswordLoginNextAction.localLogin;
  }

  return PasswordLoginNextAction.invalid;
}
