public async Task <IActionResult> ChangePasswordAsync([FromBody] ChangePasswordModel model)
        {
            if (string.IsNullOrWhiteSpace(model.ExistingPassword) ||
                string.IsNullOrWhiteSpace(model.NewPassword) ||
                string.IsNullOrWhiteSpace(model.NewPasswordConfirmation) ||
                !model.NewPassword.Equals(model.NewPasswordConfirmation, StringComparison.InvariantCultureIgnoreCase))
            {
                return(BadRequest("Password confirmation and password do not match."));
            }

            if (!_authenticationSettings.Password.Equals(EncryptPassword(model.ExistingPassword), StringComparison.InvariantCultureIgnoreCase))
            {
                return(BadRequest("The password provided was incorrect."));
            }

            AuthenticationSettingsRepository.UpdateAdminAccount(_authenticationSettings.Username, EncryptPassword(model.NewPassword));

            return(Ok(new { ok = true }));
        }
        public async Task <IActionResult> RegisterAsync([FromBody] RegistrationModel model)
        {
            if (!string.IsNullOrWhiteSpace(_authenticationSettings.Username) || !string.IsNullOrWhiteSpace(_authenticationSettings.Password))
            {
                return(Conflict("Admin account has already been created."));
            }

            if (string.IsNullOrWhiteSpace(model.Username) ||
                string.IsNullOrWhiteSpace(model.Password) ||
                string.IsNullOrWhiteSpace(model.PasswordConfirmation) ||
                !model.Password.Equals(model.PasswordConfirmation, StringComparison.InvariantCultureIgnoreCase))
            {
                return(BadRequest("Registration information was incorrect."));
            }

            AuthenticationSettingsRepository.UpdateAdminAccount(model.Username, EncryptPassword(model.Password));

            var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_authenticationSettings.PrivateKey));
            var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);

            var claims = new[]
            {
                new Claim(JwtRegisteredClaimNames.Sub, model.Username),
                new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
            };

            var token = new JwtSecurityToken(
                issuer: "Requestrr",
                audience: "Requestrr",
                claims,
                expires: DateTime.Now.AddMonths(1),
                signingCredentials: credentials
                );

            var encodedToken = new JwtSecurityTokenHandler().WriteToken(token);

            return(Ok(new { token = encodedToken }));
        }