validateAuthToken static method

CometChatCallsException? validateAuthToken(
  1. String? authToken
)

Validates authToken for login with auth token. Returns null if valid, CometChatCallsException if invalid.

Implementation

static CometChatCallsException? validateAuthToken(String? authToken) {
  if (authToken == null) {
    return CometChatCallsException(
      ErrorCodeConstants.codeAuthTokenNull,
      ErrorMessageConstants.messageCodeUserAuthTokenNull,
      ErrorDetailConstants.detailAuthTokenNull,
    );
  }
  if (authToken.trim().isEmpty) {
    return CometChatCallsException(
      ErrorCodeConstants.codeAuthTokenEmpty,
      ErrorMessageConstants.messageCodeUserAuthTokenBlankOrEmpty,
      ErrorDetailConstants.detailAuthTokenEmpty,
    );
  }
  if (CometChatCallsUtils.containsSpace(authToken)) {
    return CometChatCallsException(
      ErrorCodeConstants.codeAuthTokenHasSpace,
      ErrorMessageConstants.messageAuthTokenHasSpace,
      ErrorDetailConstants.detailAuthTokenHasSpace,
    );
  }
  return null;
}