public async Task ValidateClientAuthentication(JwtSimpleServerContext context) { var success = false; var user = await _userManager.FindByNameAsync(context.UserName); if (user != null) { success = await _userManager.CheckPasswordAsync(user, context.Password); } if (success) { var claims = new List <Claim> { new Claim(ClaimTypes.NameIdentifier, user.Id), new Claim(ClaimTypes.Name, user.UserName) }; context.Success(claims); } else { context.Reject("Invalid user authentication."); } }
public Task ValidateClientAuthentication(JwtSimpleServerContext context) { if (context.UserName == "demo" && context.Password == "demo") { var claims = new List <Claim>(); claims.Add(new Claim(ClaimTypes.Name, "demo")); context.Success(claims); } else { context.Reject("Invalid user authentication"); } return(Task.CompletedTask); }
public Task ValidateClientAuthentication(JwtSimpleServerContext context) { if (context.UserName == "sampleapi" && context.Password == "sampliapipassword") { var claims = new List <Claim> { new Claim(ClaimTypes.Name, "SampleAPI") }; context.Success(claims); } else { context.Reject("Invalid user authentication"); } return(Task.CompletedTask); }
public Task ValidateClientAuthentication(JwtSimpleServerContext context) { context.Success(Enumerable.Empty <Claim>().ToList()); return(Task.CompletedTask); }