public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {

            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });

            using (UsuarioAuthRepositorio _repo = new UsuarioAuthRepositorio())
            {
                Usuario user = await _repo.BuscarUser(context.UserName, context.Password);

                if (user == null)
                {
                    context.SetError("invalid_grant", "O nome de usuario ou senha está incorreto.");
                    return;
                }
            }

            var identity = new ClaimsIdentity(context.Options.AuthenticationType);
            identity.AddClaim(new Claim("sub", context.UserName));
            identity.AddClaim(new Claim("role", "user"));

            context.Validated(identity);

        }
Exemplo n.º 2
0
 public ContaController()
 {
     repoUser = new UsuarioAuthRepositorio();
 }
Exemplo n.º 3
0
 public UsuarioController()
 {
     repoUser = new UsuarioAuthRepositorio();
     repoAcervoCentral = new AcervoCentral();
 }