validateAuthAccountForLink function

void validateAuthAccountForLink(
  1. AuthAccount account
)

Validates an external account before it is linked to a local user.

Implementation

void validateAuthAccountForLink(AuthAccount account) {
  if (account.providerId.trim().isEmpty) {
    throw ArgumentError.value(
      account.providerId,
      'account.providerId',
      'must be non-empty',
    );
  }
  if (account.providerAccountId.trim().isEmpty) {
    throw ArgumentError.value(
      account.providerAccountId,
      'account.providerAccountId',
      'must be non-empty',
    );
  }
  final userId = account.userId;
  if (userId == null || userId.trim().isEmpty) {
    throw ArgumentError.value(
      account.userId,
      'account.userId',
      'must identify the local user being linked',
    );
  }
}