Last active
November 18, 2017 08:54
-
-
Save jjwilliams42/142aa296654a1ee77cd2e7a6c8078f65 to your computer and use it in GitHub Desktop.
Startup.cs - Configure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Test | |
{ | |
public class Startup | |
{ | |
// This method gets called by the runtime. Use this method to add services to the container. | |
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
} | |
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. | |
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | |
{ | |
if (env.IsDevelopment()) | |
{ | |
app.UseDeveloperExceptionPage(); | |
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions() | |
{ | |
HotModuleReplacement = true, | |
ReactHotModuleReplacement = true | |
}); | |
} | |
app.UseServiceStack(new AppHost()); | |
} | |
} | |
public class AppHost : AppHostBase | |
{ | |
... | |
// Configure your AppHost with the necessary configuration and dependencies your App needs | |
public override void Configure(Container container) | |
{ | |
... | |
container.Register<IPasswordHasher<User>>( | |
new PasswordHasher<User>(new OptionsWrapper<PasswordHasherOptions>(new PasswordHasherOptions() | |
{ | |
CompatibilityMode = PasswordHasherCompatibilityMode.IdentityV2 | |
}))); | |
container.Register<IPasswordHasher>(new CustomPasswordHasher(container.Resolve<IPasswordHasher<User>>())); | |
container.Register<IUserAuthRepository>(c => new CustomAuthRepository(c.Resolve<IDbConnectionFactory>())); | |
var authRepo = (CustomAuthRepository)container.Resolve<IUserAuthRepository>(); | |
authRepo.InitSchema(); | |
Plugins.AddRange(new IPlugin[] | |
{ | |
new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] | |
{ | |
new CustomAuthProvider() | |
{ | |
PersistSession = true | |
} | |
}) | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment