コード例 #1
0
ファイル: PostOng.cs プロジェクト: leonibr/hero-app-wasm
            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
ファイル: PostOng.cs プロジェクト: leonibr/hero-app-wasm
 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
ファイル: Authenticate.cs プロジェクト: leonibr/hero-app-wasm
 public Handler(IAuthUserService userService)
 {
     this.userService = userService;
 }
コード例 #11
0
        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;
 }
コード例 #15
0
 public TokenController(IAuthUserService service)
 {
     _service = service;
 }