public IActionResult GetNewToken()
        {
            string token = Request.Headers["Authorization"];
            string email = AuthControllerExtensions.JwtNameExtractor(token);

            return(Ok(new { Token = AuthControllerExtensions.GenerateToken(email), Leasetime = 30 }));
        }
        public IActionResult Login([FromBody] User user)
        {
            if (user == null)
            {
                _logger.LogError("Invalid user: object was null");
                return(BadRequest("Object sent was null"));
            }

            if (!ModelState.IsValid)
            {
                _logger.LogError("Invalid user: object was null");
                return(BadRequest("Invalid user: object was null"));
            }

            bool valid = _repository.User.ValidateUser(user);

            if (valid)
            {
                var tokenString = AuthControllerExtensions.GenerateToken(user.Email);
                return(Ok(new { Token = tokenString, Leasetime = 30 }));
            }
            else
            {
                return(Unauthorized());
            }
        }