public async Task <(string token, string refreshToken)> LoginAsync(string username, string password)
        {
            var userInDB = await repositoryWrapper.User.GetUserAsync(username);

            if (userInDB == null)
            {
                return(null, null);
            }
            if (!VerifyPasswordHash(password, userInDB.PasswordHash, userInDB.PasswordSalt))
            {
                return(null, null);
            }
            var accessToken = new Token()
            {
                AccessToken        = GenerateJSONWebToken(userInDB),
                AccessTokenExpiry  = DateTime.Now.AddMinutes(60),
                refreshToken       = GuidGenerator.Generate(),
                refreshTokenExpiry = DateTime.Now.AddMinutes(65),
                UserId             = userInDB.Id
            };

            repositoryWrapper.Token.AddToken(accessToken);
            var saveStatus = await repositoryWrapper.Complete();

            return(GenerateJSONWebToken(userInDB), GuidGenerator.Generate());
        }
        public async Task SeedDataAsync()
        {
            if (await repositoryWrapper.User.VerifyAsync() == "00")
            {
                var userData           = System.IO.File.ReadAllText(configuration["Seed:PATH"]);
                var userDataCollection = JsonConvert.DeserializeObject <List <User> >(userData);

                foreach (var user in userDataCollection)
                {
                    byte[] salt         = PasswordHasher.GenerateSalt();
                    var    passwordSalt = Convert.ToBase64String(salt);

                    var hashPassword = Convert.ToBase64String(PasswordHasher.HashPasswordWithSalt(Encoding.UTF8.GetBytes("password"), salt));

                    user.Username     = user.Username.ToLowerInvariant();
                    user.PasswordSalt = passwordSalt;
                    user.PasswordHash = hashPassword;
                    repositoryWrapper.User.CreateUser(user);
                    await repositoryWrapper.Complete();
                }
            }
        }