public BuildsController(BuildTrackerContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public async Task OnAuthorizationAsync(AuthorizationFilterContext context) { if (!context.ActionDescriptor.EndpointMetadata.Any(item => item is AllowNotConfirmed || item is AllowAnonymousFilter || item is IAllowAnonymous)) { if (!context.HttpContext.User.Identity.IsAuthenticated) { context.Result = new ForbidResult(); return; } try { var confirmed = context.HttpContext.User.HasClaim(CustomClaimTypes.AccountConfirmed, true.ToString()); //Make a call to database to ensure Consistency if (!confirmed) { BuildTrackerContext dbContext = ServiceProviderServiceExtensions.GetRequiredService <BuildTrackerContext>(context.HttpContext.RequestServices); var id = int.Parse(context.HttpContext.User.Identity?.Name); var user = await dbContext.FindAsync <User>(id); if (user == null) { context.Result = new UnauthorizedResult(); return; } else if (!user.AccountConfirmed) { var dic = new Dictionary <string, string> { { "Reason", "Account not Confirmed" }, { "AuthUrl", "api/users/confirm/" + user.Id } }; AuthenticationProperties props = new AuthenticationProperties(dic); var result = JsonConvert.SerializeObject(new { error = "Account not confirmed" }); await context.HttpContext.Response.WriteAsync(result); context.Result = new ForbidResult(props); return; } } } catch { context.Result = new ForbidResult(); return; } } }
public ProductDevelopersController(BuildTrackerContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public ValuesController(BuildTrackerContext context, IOptions <AppSettings> appSettings) { _appSettings = appSettings.Value; _context = context; }
public UserAuthorizationHandler(BuildTrackerContext context) { _context = context; }
public UserService(BuildTrackerContext context, UserManager <User> userManager, RoleManager <AppRole> roleManager) { _context = context; _userManager = userManager; _roleManager = roleManager; }