public void AuthHelper_ConvertToHashedString_ExpectNonEmpty()
        {
            List <string> list = new List <string> {
                "EG&E^&^B&E^E",
                "$%#&^*$&^*",
                "helloIamFabulous",
                "TrumpLovesKimJungEun",
                "O O L A L A"
            };

            foreach (string str in list)
            {
                string hashed = AuthHelper.ConvertToHashedString(str);
                Assert.NotEmpty(hashed);
            }
        }
        public async Task <IActionResult> Login([FromBody] UserDto userDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            string hashedPass = AuthHelper.ConvertToHashedString(userDto.password);
            var    result     = _context.Users
                                .Where(u => u.username == userDto.username && u.password == hashedPass)
                                .FirstOrDefault();

            if (result != null)
            {
                result.token = AuthHelper.CreateToken(99);
                await _context.SaveChangesAsync();

                return(Ok(new { username = result.username, token = result.token }));
            }
            return(BadRequest("invalid login"));
        }