public CarByName(IMapper mapper, CurrentUserProvider currentUserProvider, IDbContextProvider <ApplicationContext> databaseContextProvider) { this.mapper = mapper; this.currentUserProvider = currentUserProvider; this.databaseContextProvider = databaseContextProvider; }
public PermissionService(ISecurityObjectRepository SecObjectRepository, CurrentUserProvider CurrentUser, ILogger <PermissionService> _logger) { this.secObjectRepository = SecObjectRepository; this.CurrentUser = CurrentUser; this._logger = _logger; }
internal CurrentUserScope(CurrentUserProvider currentUserProvider, CurrentUserContext scopedContext) { _currentUserProvider = currentUserProvider; _previousContext = currentUserProvider.Context; _currentUserProvider.Context = scopedContext; }
public UserController(UserRepository userRepository, IPasswordHasher passwordHasher, IOptions <JwtAuthentication> jwtAuthentication, CurrentUserProvider currentUserProvider) { _userRepository = userRepository ?? throw new ArgumentNullException(nameof(userRepository)); _passwordHasher = passwordHasher ?? throw new ArgumentNullException(nameof(passwordHasher)); _jwtAuthentication = jwtAuthentication ?? throw new ArgumentNullException(nameof(jwtAuthentication)); _currentUserProvider = currentUserProvider ?? throw new ArgumentNullException(nameof(currentUserProvider)); }
public PermissionService(SecurityIdentityRepository RlsIdentityRepo, CurrentUserProvider CurrentUser, ILogger <PermissionService> _logger) { this.RlsIdentityRepo = RlsIdentityRepo; this.CurrentUser = CurrentUser; this._logger = _logger; }
public ChargesForUserByLocationAndCar(IMapper mapper, CurrentUserProvider currentUserProvider, IDbContextProvider <ApplicationContext> databaseContextProvider) { this.mapper = mapper; this.currentUserProvider = currentUserProvider; this.databaseContextProvider = databaseContextProvider; }
public InvitationByRecipient(IMapper mapper, CurrentUserProvider currentUserProvider, IDbContextProvider <ApplicationContext> databaseContextProvider) { this.mapper = mapper; this.currentUserProvider = currentUserProvider; this.databaseContextProvider = databaseContextProvider; }
private void SetLastChangeProperties(T entity, DateTime?now = null) { if (entity is ILastChangeTrackable lct) { lct.ModifiedUserId = CurrentUserProvider.GetUserId(); lct.ModifiedDateTime = now ?? DateTime.UtcNow; } }
public FavoritesController( DefaultContext dbContext, CurrentUserProvider currentUserProvider ) { this.dbContext = dbContext; this.currentUserProvider = currentUserProvider; }
public PlaceholderSecureController(IPlaceholderSecureRepository placeholderSecureRepository, IPlaceholderACLRepository placeholderACLRepository, CurrentUserProvider currentUserProvider, IMapper mapper) { PlaceholderSecureRepository = placeholderSecureRepository; PlaceholderACLRepository = placeholderACLRepository; CurrentUserProvider = currentUserProvider; Mapper = mapper; }
private void SetCreationProperties(T entity, DateTime?now = null) { if (entity is ICreationTrackable ct) { ct.CreatedUserId = CurrentUserProvider.GetUserId(); ct.CreatedDateTime = now ?? DateTime.UtcNow; } }
public CommentsController( AppConfiguration configuration, DefaultContext dbContext, CurrentUserProvider currentUserProvider ) { this.configuration = configuration; this.dbContext = dbContext; this.currentUserProvider = currentUserProvider; }
public OwnerController( IPaymentServices paymentServices, DefaultContext dbContext, CurrentUserProvider currentUserProvider ) { this.paymentServices = paymentServices; this.dbContext = dbContext; this.currentUserProvider = currentUserProvider; }
public static void UseMicroservice(this IApplicationBuilder app, IHostingEnvironment env, MicroserviceOptions microserviceOptions) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseAuthentication(); CultureInfo[] supportedCultures = new[] { "de-DE", "en-US" }.Select(code => new CultureInfo(code)).ToArray(); app.UseRequestLocalization(new RequestLocalizationOptions { DefaultRequestCulture = new RequestCulture("en-US"), // Formatting numbers, dates, etc. SupportedCultures = supportedCultures, // UI strings that we have localized. SupportedUICultures = supportedCultures }); app.UseCors(options => options .AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod() .WithExposedHeaders("X-Authentication-Hash") .AllowCredentials()); app.UseResponseCompression(); JsonExceptionMiddleware jsonExceptionMiddleware = new JsonExceptionMiddleware(app.ApplicationServices.GetRequiredService <IHostingEnvironment>()); app.UseExceptionHandler(new ExceptionHandlerOptions { ExceptionHandler = jsonExceptionMiddleware.Invoke }); app.UseSwagger(); app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/1.0/swagger.json", microserviceOptions.Swagger.Title); options.DocExpansion(DocExpansion.List); }); app.Use(async(context, next) => { CurrentUserProvider currentUserProvider = app.ApplicationServices.GetService <CurrentUserProvider>(); if (currentUserProvider != null) { context.Response.Headers.Add("X-Authentication-Hash", currentUserProvider.User.Name.ToSha256()); } await next(); }); app.UseMvcWithDefaultRoute(); }
public FlowOneController(IStateManagger stateManagger, StateChangeFactory stateChangeFactory, ITestEntityRepository testEntityRepository, IBasicTaskSecureRepository basicTaskRepository, CurrentUserProvider currentUserProvider, IUserSecurityObjectsHandler userSecurityObjectsHandler) { StateManagger = stateManagger; StateChangeFactory = stateChangeFactory; TestEntityRepository = testEntityRepository; this.secureBasicTaskRepository = basicTaskRepository; CurrentUserProvider = currentUserProvider; UserSecurityObjectsHandler = userSecurityObjectsHandler; }
public void GetCurrentUserOid_ShouldReturnOid_WhenOidExists() { var okOid = new Guid("7DFC890F-F82B-4E2D-B81B-41D6C103F83B"); var dut = new CurrentUserProvider(); dut.SetCurrentUserOid(okOid); var oid = dut.GetCurrentUserOid(); Assert.AreEqual(okOid, oid); }
public ContactController( ISiteContactFormMail mailer, AppConfiguration configuration, CurrentUserProvider currentUserProvider, DefaultContext dbContext ) { this.mailer = mailer; this.configuration = configuration; this.currentUserProvider = currentUserProvider; this.dbContext = dbContext; }
// // GET: /Object/ public ObjectController( IUniqueViewCounter viewCounter, IPaymentServices paymentServices, DefaultContext dbContext, ObjectsActivator objectsActivator, CurrentUserProvider currentUserProvider ) { this.viewCounter = viewCounter; this.paymentServices = paymentServices; this.dbContext = dbContext; this.objectsActivator = objectsActivator; this.currentUserProvider = currentUserProvider; }
// https://docs.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-2.0&tabs=aspnetcore2x#per-request-dependencies public async Task Invoke(HttpContext context, CurrentUserProvider currentUser, SecurityIdentityRepository rlsRepo, PermissionService permissionService) { RlsIdentityRepo = rlsRepo; PermissionService = permissionService; CurrentUser = currentUser; var userName = context.User.Identity.Name; _logger.LogInformation($"Invoke - {userName}"); RegisterUser(userName); await _next(context); }
public async Task AddVideoJobApplicationAsync(CreateVideoJobApplicationModel createVideoJobApplicationModel, CancellationToken cancellationToken) { var loggedInUserAzureObjectId = CurrentUserProvider.GetObjectId(); var userEntity = FairplaytubeDatabaseContext.ApplicationUser .Single(p => p.AzureAdB2cobjectId.ToString() == loggedInUserAzureObjectId); var videoJobApplicationEntity = await FairplaytubeDatabaseContext.VideoJobApplication .Include(p => p.ApplicantApplicationUser) .Include(p => p.VideoJob) .ThenInclude(p => p.VideoInfo) .ThenInclude(p => p.ApplicationUser) .SingleOrDefaultAsync(p => p.VideoJobId == createVideoJobApplicationModel.VideoJobId && p.ApplicantApplicationUser.AzureAdB2cobjectId.ToString() == loggedInUserAzureObjectId, cancellationToken: cancellationToken); if (videoJobApplicationEntity is not null) { throw new CustomValidationException(Localizer[UserApplicationAlreadyExistsTextKey]); } var videoJobEntity = await FairplaytubeDatabaseContext.VideoJob .Include(p => p.VideoInfo).ThenInclude(p => p.ApplicationUser) .SingleAsync(p => p.VideoJobId == createVideoJobApplicationModel.VideoJobId, cancellationToken: cancellationToken); if (videoJobEntity.VideoInfo.ApplicationUser .AzureAdB2cobjectId.ToString() == loggedInUserAzureObjectId) { throw new CustomValidationException(Localizer[CannotApplyToOwnedVideosJobsTextKey]); } videoJobApplicationEntity = new VideoJobApplication() { ApplicantApplicationUserId = userEntity.ApplicationUserId, ApplicantCoverLetter = createVideoJobApplicationModel.ApplicantCoverLetter, VideoJobId = createVideoJobApplicationModel.VideoJobId.Value, VideoJobApplicationStatusId = (short)Common.Global.Enums.VideoJobApplicationStatus.New }; await FairplaytubeDatabaseContext.VideoJobApplication.AddAsync(videoJobApplicationEntity, cancellationToken); await FairplaytubeDatabaseContext.SaveChangesAsync(cancellationToken); string message = String.Format(Localizer[UserHasAppliedToJobTextKey], videoJobEntity.VideoInfo.ApplicationUser.FullName, videoJobEntity.Title); await HubContext.Clients.User(videoJobEntity.VideoInfo .ApplicationUser.AzureAdB2cobjectId.ToString()) .ReceiveMessage(new Models.Notifications.NotificationModel() { Message = message }); }
// https://docs.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-2.0&tabs=aspnetcore2x#per-request-dependencies public async Task Invoke(HttpContext context, CurrentUserProvider currentUser, PermissionService permissionService) { var userName = context.User.Identity.Name; _logger.LogInformation($"Invoke - {userName}"); currentUser.SetIdentifier(userName); SecurityIdentity identity; lock (lockObj) { identity = permissionService.RegisterUserIfNotExists(userName ?? "Anonymous"); } currentUser.SetUser(identity); await _next(context); }
public EditCar(CurrentUserProvider currentUserProvider) { this.currentUserProvider = currentUserProvider; }
public EditLocation(CurrentUserProvider currentUserProvider) { this.currentUserProvider = currentUserProvider; }
public UserIsLocationOwner(CurrentUserProvider currentUserProvider, IDbContextProvider <ApplicationContext> databaseContextProvider) { this.currentUserProvider = currentUserProvider; this.databaseContextProvider = databaseContextProvider; }
public RejectInvitation(CurrentUserProvider currentUserProvider) { this.currentUserProvider = currentUserProvider; }
public AddCar(CurrentUserProvider currentUserProvider) { this.currentUserProvider = currentUserProvider; }
public InvitationForEmailDoesNotExist(CurrentUserProvider currentUserProvider, IDbContextProvider <ApplicationContext> databaseContextProvider) { this.currentUserProvider = currentUserProvider; this.databaseContextProvider = databaseContextProvider; }
public DeleteLocation(CurrentUserProvider currentUserProvider) { this.currentUserProvider = currentUserProvider; }
public LocationWithNameDoesNotExist(CurrentUserProvider currentUserProvider, IDbContextProvider <ApplicationContext> databaseContextProvider) { this.currentUserProvider = currentUserProvider; this.databaseContextProvider = databaseContextProvider; }
public void GetCurrentUserOid_ThrowsException_WhenOidDoesNotExist() { var dut = new CurrentUserProvider(); Assert.ThrowsException <Exception>(() => dut.GetCurrentUserOid()); }