예제 #1
0
            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");
            }
예제 #2
0
 public Handler(IMapper mapper, IHeroContext heroContext, IGenerateIdService generateIdService, IAuthUserService authUser)
 {
     this.mapper            = mapper;
     this.heroContext       = heroContext;
     this.generateIdService = generateIdService;
     this.authUser          = authUser;
 }
예제 #3
0
 public BillDetailController(IBillDetailService billDetailService, IHostingEnvironment host, IProductService productService, IAuthUserService authUserService, IBillService billService)
 {
     _billDetailService = billDetailService;
     _host            = host;
     _productService  = productService;
     _authUserService = authUserService;
     _billService     = billService;
 }
예제 #4
0
        public AuthController(
            IAuthUserService user,
            IRoleService role,
            IUserDeviceService device

            ) : base(user, role, device)
        {
            //_checkDevice = checkDevice;
        }
예제 #5
0
 public AuthUsersController(
     IAuthUserService userService,
     IMapper mapper,
     IOptions <AppSettings> appSettings)
 {
     _userService = userService;
     _mapper      = mapper;
     _appSettings = appSettings.Value;
 }
예제 #6
0
        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);
        }
예제 #7
0
 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 = "******"
     };
 }
예제 #8
0
 public TCContext(DbContextOptions <TCContext> options, IAuthUserService authUserService) : base(options)
 {
     _Options         = options;
     _AuthUserService = authUserService;
 }
예제 #9
0
 public AuthUserController(IAuthUserService authUserService, IHostingEnvironment host, IOptions <AppSetting> appSetting)
 {
     _authUserService = authUserService;
     _host            = host;
     _appSetting      = appSetting.Value;
 }
예제 #10
0
 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);
        }
예제 #12
0
 public AuthController(IAuthUserService authUserService)
 {
     _authUserService = authUserService;
 }
예제 #13
0
 public PhrasesController(IAuthUserService authUserService, IPhraseService phraseService)
 {
     _authUserService = authUserService;
     _phraseService   = phraseService;
 }
예제 #14
0
 public AuthUserAppService(IAuthUserService authUserService)
 {
     _selfAuthUserService = authUserService;
 }
 public TokenController(IAuthUserService service)
 {
     _service = service;
 }