public CommandValidator(IAuthUserService authUser) { CascadeMode = CascadeMode.StopOnFirstFailure; this.authUser = authUser; RuleFor(c => c.Email).MustAsync(NotExistEmail).WithMessage("We already have your email. Click I forgot"); }
public Handler(IMapper mapper, IHeroContext heroContext, IGenerateIdService generateIdService, IAuthUserService authUser) { this.mapper = mapper; this.heroContext = heroContext; this.generateIdService = generateIdService; this.authUser = authUser; }
public BillDetailController(IBillDetailService billDetailService, IHostingEnvironment host, IProductService productService, IAuthUserService authUserService, IBillService billService) { _billDetailService = billDetailService; _host = host; _productService = productService; _authUserService = authUserService; _billService = billService; }
public AuthController( IAuthUserService user, IRoleService role, IUserDeviceService device ) : base(user, role, device) { //_checkDevice = checkDevice; }
public AuthUsersController( IAuthUserService userService, IMapper mapper, IOptions <AppSettings> appSettings) { _userService = userService; _mapper = mapper; _appSettings = appSettings.Value; }
static async Task Main(string[] args) { int result = 1; Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); Configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? Environments.Production}.json", optional: true) .AddEnvironmentVariables() .Build(); Log.Logger = new LoggerConfiguration() .ReadFrom.Configuration(Configuration) .Enrich.FromLogContext() .CreateLogger(); try { Log.Information("App started"); var serviceCollection = new ServiceCollection(); ConfigureServices(serviceCollection); ServiceProvider serviceProvider = serviceCollection.BuildServiceProvider(); // call user validation string authService = serviceProvider.GetService <IOptions <SettingsModel> >().Value.AuthService; IAuthUserService authUserService = serviceProvider.GetService <Func <string, IAuthUserService> >()(authService); await authUserService.Validate(args); // OK result = 0; } catch (UnauthorizedAccessException ex) { Log.Fatal(ex, "Unauthorized"); // NOK result = 1; } catch (Exception ex) { Log.Fatal(ex, "App terminated unexpectedly"); // NOK result = 1; } finally { Log.Information("App finished"); Log.CloseAndFlush(); } Environment.Exit(result); }
public void Setup() { _config = new Mock <IConfiguration>(); _config.Setup(c => c["Jwt:Key"]).Returns("ThisismySecretKey"); _repository = new AuthUserRepository(_config.Object); _service = new AuthUserService(_repository); _controller = new TokenController(_service); user1 = new Users() { Email = "admin", Password = "******" }; user2 = new Users() { Email = "Admi", Password = "******" }; }
public TCContext(DbContextOptions <TCContext> options, IAuthUserService authUserService) : base(options) { _Options = options; _AuthUserService = authUserService; }
public AuthUserController(IAuthUserService authUserService, IHostingEnvironment host, IOptions <AppSetting> appSetting) { _authUserService = authUserService; _host = host; _appSetting = appSetting.Value; }
public Handler(IAuthUserService userService) { this.userService = userService; }
public static ChangeTracker ApplyAuditInformation(this ChangeTracker tracker, IAuthUserService authUserService) { string username = authUserService.Username; foreach (EntityEntry entry in tracker.Entries()) { if (entry.Entity is IStatusAudit) { if (entry.State == EntityState.Added) { entry.CurrentValues[nameof(IStatusAudit.Status)] = Status.Active.ToString(); } if (entry.State == EntityState.Deleted) { entry.CurrentValues[nameof(IStatusAudit.Status)] = Status.Deleted.ToString(); entry.State = EntityState.Modified; } } if (entry.Entity is IModificationAudit) { if (entry.State == EntityState.Added) { entry.CurrentValues[nameof(IModificationAudit.CreatedBy)] = username; entry.CurrentValues[nameof(IModificationAudit.CreatedDate)] = DateTime.UtcNow; } else if (entry.State == EntityState.Modified) { entry.CurrentValues[nameof(IModificationAudit.UpdatedBy)] = username; entry.CurrentValues[nameof(IModificationAudit.UpdatedDate)] = DateTime.UtcNow; } } } return(tracker); }
public AuthController(IAuthUserService authUserService) { _authUserService = authUserService; }
public PhrasesController(IAuthUserService authUserService, IPhraseService phraseService) { _authUserService = authUserService; _phraseService = phraseService; }
public AuthUserAppService(IAuthUserService authUserService) { _selfAuthUserService = authUserService; }
public TokenController(IAuthUserService service) { _service = service; }