// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseApplicationInsightsRequestTelemetry(); if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); // For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859 try { using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>() .CreateScope()) { serviceScope.ServiceProvider.GetService <ApplicationDbContext>() .Database.Migrate(); } } catch { } } app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear()); app.UseApplicationInsightsExceptionTelemetry(); app.UseStaticFiles(); app.UseIdentity(); // To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715 app.UseSession(); var httpContextAccessor = app.ApplicationServices.GetRequiredService <IHttpContextAccessor>(); LoginVerify.Configure(httpContextAccessor); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Accounts}/{action=Startup}/{id?}"); }); SeedData.Initialize(app.ApplicationServices); }
public async Task <IActionResult> Home(LoginViewModel model) { if (ModelState.IsValid) { LoginVerify login = new LoginVerify(_context); if (login.verifyDoctorDetails(model.Email, model.Password)) { var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, false, lockoutOnFailure : false); if (result.Succeeded) { return(RedirectToAction("Home", "Doctors")); } else { ModelState.AddModelError(string.Empty, "Invalid login attempt."); return(View("LoginPage", model)); } } else if (login.verifyAdminDetails(model.Email, model.Password)) { var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, false, lockoutOnFailure : false); if (result.Succeeded) { return(RedirectToAction("Home", "Admin")); } else { ModelState.AddModelError(string.Empty, "Invalid login attempt."); return(View("LoginPage", model)); } } } return(View("LoginPage", model)); }