Esempio n. 1
0
        public IActionResult Login([FromBody] LoginModel login)
        {
            if (!this._userService.Verify(login.Account, login.Password))
            {
                return(Unauthorized());
            }

            var claims = new List <Claim>
            {
                new Claim("rol", "Admin"),
                new Claim("nam", login.Account)
            };
            var token = JwtGenerator.GeneratorToken(_config["Jwt:Issuer"], _config["Jwt:Issuer"], _config["Jwt:Key"],
                                                    SecurityAlgorithms.HmacSha256, claims, 30);

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