Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // https://docs.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-2.2&tabs=visual-studio
- public void ConfigureServices(IServiceCollection services)
- {
- services.Configure<CookiePolicyOptions>(options =>
- {
- options.CheckConsentNeeded = context => true;
- options.MinimumSameSitePolicy = SameSiteMode.None;
- });
- services.AddDbContext<ApplicationDbContext>(options =>
- options.UseSqlServer(
- Configuration.GetConnectionString("DefaultConnection")));
- services.AddIdentity<IdentityUser, IdentityRole>()
- // services.AddDefaultIdentity<IdentityUser>()
- .AddEntityFrameworkStores<ApplicationDbContext>()
- .AddDefaultTokenProviders();
- services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
- .AddRazorPagesOptions(options =>
- {
- options.AllowAreas = true;
- options.Conventions.AuthorizeAreaFolder("Identity", "/Account/Manage");
- options.Conventions.AuthorizeAreaPage("Identity", "/Account/Logout");
- });
- services.ConfigureApplicationCookie(options =>
- {
- options.LoginPath = $"/Identity/Account/Login";
- options.LogoutPath = $"/Identity/Account/Logout";
- options.AccessDeniedPath = $"/Identity/Account/AccessDenied";
- });
- // using Microsoft.AspNetCore.Identity.UI.Services;
- services.AddSingleton<IEmailSender, EmailSender>();
- }
- // create EmailSender service
- public class EmailSender : IEmailSender
- {
- public Task SendEmailAsync(string email, string subject, string message)
- {
- return Task.CompletedTask;
- }
- }
- // and scaffold identity razor templates
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement