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); }
public void Configure(IAppHost appHost) { var mqServer = appHost.Resolve <IMessageService>(); mqServer.RegisterHandler <TestMq>(appHost.ExecuteMessage); appHost.AssertPlugin <SharpPagesFeature>().ScriptMethods.Add(new MqScripts(mqServer)); }
public void Configure(IAppHost appHost) { var authRepo = appHost.Resolve <IAuthRepository>(); authRepo.InitSchema(); //CreateUser(authRepo, "*****@*****.**", "Admin User", "p@55wOrd", roles:new[]{ RoleNames.Admin }); }
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" }); }
public void Configure(IAppHost appHost) { var authRepo = appHost.Resolve <IAuthRepository>(); authRepo.InitSchema(); CreateUser(authRepo, "*****@*****.**", "Admin User", "p@33wOrd", roles: new[] { RoleNames.Admin }); }
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>()); }
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 }); }
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'])" }, });
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); });
public void Configure(IAppHost appHost) { appHost.Plugins.Add(new ValidationFeature()); appHost.Resolve <IValidationSource>().InitSchema(); }
public void Configure(IAppHost appHost) { CreateUser(appHost.Resolve <IAuthRepository>(), "*****@*****.**", "Admin User", "p@55wOrd", roles: new[] { RoleNames.Admin }); }
public void AfterInit(IAppHost appHost) { appHost.Resolve <IMessageService>().Start(); }