Пример #1
0
        private async Task <string> GetUniqueKeyId()
        {
            const int attempts = 4;
            string    keyId    = null;

            for (int i = 0; i < 4; i++)
            {
                keyId = GetRandomSecret(4);
                if (await apiKeyRepository.IsCredentialUsernameAvailableAsync(keyId))
                {
                    return(keyId);
                }
            }
            throw new SystemException($"Failed to create unique 'KeyId' in {attempts} attempts");
        }