Exemple #1
0
        private bool IsAdmin(AdminModel admin)
        {
            // app for now have only 1 admin so his hard coded
            string validName     = "Admin";
            string validPassword = "******";

            return(admin.Name == validName && admin.Password == validPassword);
        }
Exemple #2
0
        public IActionResult Login([FromBody] AdminModel admin)
        {
            IActionResult response = Unauthorized();

            if (IsAdmin(admin))
            {
                var tokenString = GenerateJSONWebToken();
                response = Ok(new { token = tokenString });
                _logger.LogInformation("admin logged in");
            }
            return(response);
        }