public IdentityRepository() { var settings = SecuritySettings.FromConfiguration(); settings.RequireAccountVerification = false; var config = new MembershipRebootConfiguration(settings); var uarepo = new BrockAllen.MembershipReboot.Ef.DefaultUserAccountRepository(); this.userSvc = new UserAccountService(config, uarepo); this.userQuery = uarepo; var grpRepo = new BrockAllen.MembershipReboot.Ef.DefaultGroupRepository(); this.groupSvc = new GroupService(config.DefaultTenant, grpRepo); this.groupQuery = grpRepo; }
private void InitDb() { using (var db = new BrockAllen.MembershipReboot.Ef.DefaultUserAccountRepository()) { var svc = new UserAccountService(db); if (svc.GetByUsername("admin") == null) { var account = svc.CreateAccount("admin", "admin123", "*****@*****.**"); svc.VerifyAccount(account.VerificationKey); account = svc.GetByID(account.ID); account.AddClaim(ClaimTypes.Role, "Administrator"); account.AddClaim(ClaimTypes.Role, "Manager"); account.AddClaim(ClaimTypes.Country, "USA"); svc.Update(account); } } }
public async Task Invoke(IDictionary <string, object> env) { var ctx = new OwinContext(env); using (var db = new BrockAllen.MembershipReboot.Ef.DefaultUserAccountRepository()) { var settings = SecuritySettings.FromConfiguration(); var mrConfig = new MembershipRebootConfiguration(settings); mrConfig.ConfigureCookieBasedTwoFactorAuthPolicy(new OwinCookieBasedTwoFactorAuthPolicy(env)); var appInfo = new OwinApplicationInformation(env, "Test", "Test Email Signature", "UserAccount/Login", "UserAccount/Register/Confirm/", "UserAccount/Register/Cancel/", "UserAccount/PasswordReset/Confirm/", "UserAccount/ChangeEmail/Confirm/"); var emailFormatter = new EmailMessageFormatter(appInfo); if (settings.RequireAccountVerification) { // uncomment if you want email notifications -- also update smtp settings in web.config //config.AddEventHandler(new EmailAccountCreatedEventHandler(emailFormatter)); } // uncomment if you want email notifications -- also update smtp settings in web.config //config.AddEventHandler(new EmailAccountEventsHandler(emailFormatter)); var uaSvc = new UserAccountService(mrConfig, db); var anSvc = new OwinAuthenticationService(uaSvc, env); try { ctx.SetUserAccountService(uaSvc); ctx.SetAuthenticationService(anSvc); await next(env); } finally { ctx.SetUserAccountService(null); ctx.SetAuthenticationService(null); } } }
public async Task Invoke(IDictionary<string, object> env) { var ctx = new OwinContext(env); using (var db = new BrockAllen.MembershipReboot.Ef.DefaultUserAccountRepository()) { var settings = SecuritySettings.FromConfiguration(); var mrConfig = new MembershipRebootConfiguration(settings); mrConfig.ConfigureCookieBasedTwoFactorAuthPolicy(new OwinCookieBasedTwoFactorAuthPolicy(env)); var appInfo = new OwinApplicationInformation(env, "Test", "Test Email Signature", "UserAccount/Login", "UserAccount/Register/Confirm/", "UserAccount/Register/Cancel/", "UserAccount/PasswordReset/Confirm/", "UserAccount/ChangeEmail/Confirm/"); var emailFormatter = new EmailMessageFormatter(appInfo); if (settings.RequireAccountVerification) { // uncomment if you want email notifications -- also update smtp settings in web.config //config.AddEventHandler(new EmailAccountCreatedEventHandler(emailFormatter)); } // uncomment if you want email notifications -- also update smtp settings in web.config //config.AddEventHandler(new EmailAccountEventsHandler(emailFormatter)); var uaSvc = new UserAccountService(mrConfig, db); var anSvc = new OwinAuthenticationService(uaSvc, env); try { ctx.SetUserAccountService(uaSvc); ctx.SetAuthenticationService(anSvc); await next(env); } finally { ctx.SetUserAccountService(null); ctx.SetAuthenticationService(null); } } }