コード例 #1
0
        public async Task <NonceContract> CreateAsync(
            int userId,
            NonceTypeEnum nonceType
            )
        {
            var nonceContract = new NonceContract
            {
                UserId = userId,
                Type   = nonceType,
            };

            using (var nonceResponse =
                       await m_authorizationServiceHttpClient.SendRequestAsync(HttpMethod.Post, $"{BasePath}create", nonceContract))
            {
                return(await m_authorizationServiceHttpClient.GetDeserializedModelAsync <NonceContract>(nonceResponse));
            }
        }
コード例 #2
0
        public bool IsNonceKeyValid(string nonce, int userId, NonceTypeEnum nonceType)
        {
            if (nonce == null)
            {
                throw new ArgumentException();
            }

            if (m_memoryCache.TryGetValue(nonce, out NonceContract nonceContract))
            {
                var isValid = nonceContract.UserId == userId &&
                              nonceContract.Type == nonceType;

                m_memoryCache.Remove(nonce);

                return(isValid);
            }

            return(false);
        }
コード例 #3
0
 public bool IsNonceKeyValid(string nonce, NonceTypeEnum nonceType)
 {
     return(IsNonceKeyValid(nonce, 0, nonceType));
 }