Skip to content

Instantly share code, notes, and snippets.

@jackjwilliams jackjwilliams/Startup.cs
Last active Nov 18, 2017

Embed
What would you like to do?
Startup.cs - Configure
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
You can’t perform that action at this time.