private IEnumerable <Claim> GenerateClaims(string email, string password)
        {
            var userClaimId  = UniqueIdGenerationService.GenerateRandomId();
            var passwordHash = Convert.ToBase64String(SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes(password)));

            using (var dbContext = HttpContextAccessor.HttpContext.RequestServices.GetService(typeof(DissertationThesisContext)) as DissertationThesisContext)
            {
                var user = dbContext.Users.FirstOrDefault(x => x.User == email && x.PasswordHash == passwordHash);

                if (user == null)
                {
                    dbContext.Users.Add(new Users
                    {
                        Id           = userClaimId,
                        User         = email,
                        PasswordHash = passwordHash,
                        Role         = "Member"
                    });

                    dbContext.SaveChanges();
                }

                userClaimId = user.Id;
            }

            return(new List <Claim>
            {
                new Claim("id", userClaimId),
                new Claim("user", email),
                new Claim("hash", passwordHash),
                new Claim("role", "Member")
            });
        }
        public Task <IEnumerable <DataContract> > GetDataContracts(IEnumerable <DecryptedData> decryptedData)
        {
            var publicKeyPaths = this.FileAccessor.GetLocalPublicKeyTemporaryPaths();
            var dataContracts  = new List <DataContract>();

            foreach (var item in decryptedData)
            {
                var jsonData   = JsonConvert.SerializeObject(item);
                var binaryData = Encoding.UTF8.GetBytes(jsonData);

                var inputTempFilePath = Path.Combine(this.RootPath, "temp.bin");
                File.WriteAllBytes(inputTempFilePath, binaryData);

                var outputTempFilePath = this.DataProtector.EncryptFile(inputTempFilePath, publicKeyPaths);
                var encryptedData      = File.ReadAllBytes(outputTempFilePath);

                dataContracts.Add(new DataContract()
                {
                    PacketId      = UniqueIdGenerationService.GenerateRandomId(),
                    UserId        = App.USER_ID,
                    EncryptedData = Convert.ToBase64String(encryptedData)
                });

                File.Delete(inputTempFilePath);
                File.Delete(outputTempFilePath);
            }

            publicKeyPaths.All(p =>
            {
                File.Delete(p);

                return(true);
            });

            return(Task.FromResult(dataContracts.AsEnumerable()));
        }