Пример #1
0
        public void Configure(IAppHost appHost)
        {
            // Create non-existing Table and add Seed Data Example
            using var db = appHost.Resolve <IDbConnectionFactory>().Open();
            if (db.CreateTableIfNotExists <Booking>())
            {
                db.CreateBooking("First Booking!", RoomType.Queen, 10, 100, "*****@*****.**");
                db.CreateBooking("Booking 2", RoomType.Double, 12, 120, "*****@*****.**");
                db.CreateBooking("Booking the 3rd", RoomType.Suite, 13, 130, "*****@*****.**");
            }

            using var dbPgsql = appHost.Resolve <IDbConnectionFactory>().Open("pgsql");
            if (dbPgsql.CreateTableIfNotExists <Table1>())
            {
                dbPgsql.Insert(new Table1 {
                    Name = "Table1"
                });
            }
            if (dbPgsql.CreateTableIfNotExists <Table2>())
            {
                dbPgsql.Insert(new Table2 {
                    Name = "Table2"
                });
            }
        }
        public void Configure(IAppHost appHost)
        {
            var authRepo = (IUserAuthRepository)appHost.Resolve <IAuthRepository>();

            authRepo.InitSchema();
            AddSeedUsers(authRepo);
        }
Пример #3
0
        public void Configure(IAppHost appHost)
        {
            var mqServer = appHost.Resolve <IMessageService>();

            mqServer.RegisterHandler <TestMq>(appHost.ExecuteMessage);
            appHost.AssertPlugin <SharpPagesFeature>().ScriptMethods.Add(new MqScripts(mqServer));
        }
Пример #4
0
        public void Configure(IAppHost appHost)
        {
            var authRepo = appHost.Resolve <IAuthRepository>();

            authRepo.InitSchema();
            //CreateUser(authRepo, "*****@*****.**", "Admin User", "p@55wOrd", roles:new[]{ RoleNames.Admin });
        }
Пример #5
0
        public void AfterPluginsLoaded(IAppHost appHost)
        {
            var authRepo = appHost.Resolve <IAuthRepository>();

            authRepo.InitSchema();

            // Register Users that don't exist
            void EnsureUser(string email, string name, string[] roles = null)
            {
                if (authRepo.GetUserAuthByUserName(email) != null)
                {
                    return;
                }

                authRepo.CreateUserAuth(new UserAuth {
                    Email       = email,
                    DisplayName = name,
                    Roles       = roles?.ToList(),
                }, password: "******");
            }

            EnsureUser("*****@*****.**", name: "A Employee", roles: new[] { "Employee" });
            EnsureUser("*****@*****.**", name: "Account Dept", roles: new[] { "Employee", "Accounts" });
            EnsureUser("*****@*****.**", name: "The Manager", roles: new[] { "Employee", "Manager" });
        }
Пример #6
0
        public void Configure(IAppHost appHost)
        {
            var authRepo = appHost.Resolve <IAuthRepository>();

            authRepo.InitSchema();

            CreateUser(authRepo, "*****@*****.**", "Admin User", "p@33wOrd", roles: new[] { RoleNames.Admin });
        }
Пример #7
0
        public void Configure(IAppHost appHost)
        {
            var authRepo = appHost.Resolve <IAuthRepository>();

            authRepo.InitSchema();

            CreateUser(authRepo, "*****@*****.**", "Admin User", "R3c3ption", roles: new[] { RoleNames.Admin });
        }
        public void Configure(IAppHost appHost)
        {
            var authRepo = appHost.Resolve <IAuthRepository>();

            authRepo.InitSchema();

            CreateUser(authRepo, "*****@*****.**", "Ari", "Ender", "ItKN$!Mh1r8EeY^Cd^2", roles: new[] { RoleNames.Admin });
            CreateUser(authRepo, "*****@*****.**", "Greg", "Greg", "F&6ItKN$!Md^2", Array.Empty <string>());
        }
Пример #9
0
        public void Configure(IAppHost appHost)
        {
            var authRepo = appHost.Resolve <IAuthRepository>();

            authRepo.InitSchema();

            CreateUser(authRepo, "*****@*****.**", "Admin User", "p@55wOrd", roles: new[] { RoleNames.Admin });

            //ImportTechStackUsers((OrmLiteConnectionFactory) appHost.Resolve<IDbConnectionFactory>(), authRepo);
        }
        public void Configure(IAppHost appHost)
        {
            appHost.GetContainer().AddSingleton <IAuthRepository>(c =>
                                                                  new InMemoryAuthRepository <AppUser, UserAuthDetails>());
            var authRepo = appHost.Resolve <IAuthRepository>();

            authRepo.InitSchema();

            CreateUser(authRepo, "*****@*****.**", "Admin User", "p@55wOrd", roles: new[] { RoleNames.Admin });
        }
Пример #11
0
        public void Configure(IAppHost appHost)
        {
            var validationSource = appHost.Resolve <IValidationSource>();

            validationSource.InitSchema();

            validationSource.SaveValidationRulesAsync(new List <ValidationRule> {
                new() { Type = nameof(DynamicIsAuthenticated), Validator = nameof(ValidateScripts.IsAuthenticated) },
                new() { Type = nameof(DynamicIsAdmin), Validator = nameof(ValidateScripts.IsAdmin) },
                new() { Type = nameof(DynamicHasRole), Validator = "HasRole('TheRole')" },
                new() { Type = nameof(DynamicHasPermissions), Validator = "HasPermissions(['Perm1','Perm2'])" },
            });
Пример #12
0
        private static void SetupExceptionShielding(IAppHost appHost)
        {
            appHost.ServiceExceptionHandlers.Add((httpReq, request, exception) =>
            {
                if (IsUnexpectedException(exception))
                {
                    var error    = DtoUtils.CreateResponseStatus(exception, request, true);
                    var recorder = appHost.Resolve <IRecorder>();
                    var callerId = appHost.TryResolve <ICurrentCaller>()?.Id;
                    recorder.Crash(CrashLevel.NonCritical, exception, callerId, error.StackTrace);

                    return(DtoUtils.CreateErrorResponse(request, WrapInUnhandledException(exception)));
                }

                return(null);
            });

            appHost.UncaughtExceptionHandlers.Add((request, response, operationName, exception) =>
            {
                var recorder = appHost.Resolve <IRecorder>();
                var callerId = appHost.TryResolve <ICurrentCaller>()?.Id;
                recorder.Crash(CrashLevel.Critical, WrapInUnhandledException(exception), callerId);
                response.EndRequest(true);
            });
Пример #13
0
 public void Configure(IAppHost appHost)
 {
     appHost.Plugins.Add(new ValidationFeature());
     appHost.Resolve <IValidationSource>().InitSchema();
 }
Пример #14
0
 public void Configure(IAppHost appHost)
 {
     CreateUser(appHost.Resolve <IAuthRepository>(),
                "*****@*****.**", "Admin User", "p@55wOrd", roles: new[] { RoleNames.Admin });
 }
Пример #15
0
 public void AfterInit(IAppHost appHost)
 {
     appHost.Resolve <IMessageService>().Start();
 }