public async Task <bool> SaveAsync(IServiceTokenEntity token)
        {
            try
            {
                var pk     = ServiceTokenEntity.GeneratePartitionKey();
                var sToken = await _tableStorage.GetDataAsync(pk, token.RowKey);

                var sNewToken = (ServiceTokenEntity)token;

                if (sToken == null)
                {
                    sToken = new ServiceTokenEntity
                    {
                        PartitionKey = ServiceTokenEntity.GeneratePartitionKey(),
                        RowKey       = token.RowKey,
                        ETag         = token.ETag
                    };
                }

                sToken.SecurityKeyOne = sNewToken.SecurityKeyOne;
                sToken.SecurityKeyTwo = sNewToken.SecurityKeyTwo;
                await _tableStorage.InsertOrMergeAsync(sToken);
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Exemple #2
0
        public async Task SaveTokenHistoryAsync(IServiceTokenEntity token, string userName, string userIpAddress)
        {
            var th = new ServiceTokenHistoryEntity
            {
                RowKey        = DateTime.UtcNow.StorageString(),
                UserName      = userName,
                KeyOne        = token.SecurityKeyOne,
                KeyTwo        = token.SecurityKeyTwo,
                TokenId       = token.RowKey,
                UserIpAddress = userIpAddress
            };

            await _tableStorage.InsertOrMergeAsync(th);
        }