public void Verify(AuthVerifyDTO authTokenDTO)
        {
            if (authTokenDTO.ValueRaw == null)
            {
                throw new ArgumentNullException("password");
            }
            if (string.IsNullOrWhiteSpace(authTokenDTO.ValueRaw))
            {
                throw new ArgumentException("Value cannot be empty or whitespace only string.", "password");
            }
            if (authTokenDTO.ValueHash.Length != 64)
            {
                throw new ArgumentException("Invalid length of password hash (64 bytes expected).", "passwordHash");
            }
            if (authTokenDTO.ValueSalt.Length != 128)
            {
                throw new ArgumentException("Invalid length of password salt (128 bytes expected).", "passwordHash");
            }

            using (var hmac = new HMACSHA512(authTokenDTO.ValueSalt))
            {
                byte[] chunk        = Encoding.UTF8.GetBytes(authTokenDTO.ValueRaw);
                var    computedHash = hmac.ComputeHash(chunk);
                for (int i = 0; i < computedHash.Length; i++)
                {
                    if (computedHash[i] != authTokenDTO.ValueHash[i])
                    {
                        throw new AuthVerifyFailException();
                    }
                    ;
                }
            }
        }
        public UserSignInResultDTO UserSignIn(UserSignInDTO userSignInDTO)
        {
            AccountFindResultDTO accountFindResultDTO = _accountService.Find(userSignInDTO.Email);
            //TODO migrate to _accountService
            AuthVerifyDTO authVerifyDTO = new AuthVerifyDTO {
                ValueRaw  = userSignInDTO.Password,
                ValueSalt = accountFindResultDTO.PasswordSalt,
                ValueHash = accountFindResultDTO.PasswordHash
            };

            _authService.Verify(authVerifyDTO);
            AuthTokenDTO authTokenDTO = new AuthTokenDTO {
                SubjectRaw = new Dictionary <string, string>
                {
                    ["id"] = userSignInDTO.Email
                },
                Claims = new Dictionary <string, object>()
            };
            AuthTokenResultDTO authTokenResultDTO = _authService.AuthToken(authTokenDTO);

            return(new UserSignInResultDTO {
                Token = authTokenResultDTO.Token
            });
        }