protected void LogIn(object sender, EventArgs e) { if (IsValid) { var context = new ApplicationDbContext(); var signinUser = context.Users.FirstOrDefault(u => u.UserName == UserName.Text); if (signinUser!= null && !signinUser.IsDeleted) { // Validate the user password IAuthenticationManager manager = new AuthenticationIdentityManager(new IdentityStore(new ApplicationDbContext())).Authentication; IdentityResult result = manager.CheckPasswordAndSignIn(Context.GetOwinContext().Authentication, UserName.Text, Password.Text, RememberMe.Checked); if (result.Success) { OpenAuthProviders.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response); } else { FailureText.Text = result.Errors.FirstOrDefault(); ErrorMessage.Visible = true; } } else { FailureText.Text = "Please register"; ErrorMessage.Visible = true; } } }
protected void LogIn(object sender, EventArgs e) { if (IsValid) { // Validate the user password IAuthenticationManager manager = new AuthenticationIdentityManager(new IdentityStore(new ApplicationDbContext())).Authentication; IdentityResult result = manager.CheckPasswordAndSignIn(Context.GetOwinContext().Authentication, UserName.Text, Password.Text, RememberMe.Checked); if (result.Success) { var context = new ApplicationDbContext(); var curUserName = UserName.Text; var userId = context.Users.FirstOrDefault(u => u.UserName == curUserName).Id; var userRole = context.UserRoles.FirstOrDefault(u => u.UserId == userId).Role.Name; if (userRole == "Banned") { ErrorSuccessNotifier.AddErrorMessage("You are banned!"); return; } OpenAuthProviders.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response); } else { ErrorSuccessNotifier.AddErrorMessage(result.Errors.FirstOrDefault()); } } }
protected void LogIn(object sender, EventArgs e) { if (IsValid) { // Validate the user password IAuthenticationManager manager = new AuthenticationIdentityManager(new IdentityStore()).Authentication; IdentityResult result = manager.CheckPasswordAndSignIn(Context.GetOwinContext().Authentication, UserName.Text, Password.Text, RememberMe.Checked); if (result.Success) { OpenAuthProviders.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response); } else { var errorMessageText = result.Errors.FirstOrDefault(); FailureText.Text = errorMessageText; ErrorMessage.Visible = true; ErrorSuccessNotifier.AddErrorMessage(errorMessageText); } } else { ErrorSuccessNotifier.AddErrorMessage( "An unexpected error occured! Please refresh the page..."); } }
protected void LogIn(object sender, EventArgs e) { if (IsValid) { // Validate the user password IAuthenticationManager manager = new AuthenticationIdentityManager(new IdentityStore(new ApplicationDbContext())).Authentication; IdentityResult result = manager.CheckPasswordAndSignIn(Context.GetOwinContext().Authentication, UserName.Text, Password.Text, RememberMe.Checked); if (result.Success) { OpenAuthProviders.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response); } else { ErrorSuccessNotifier.AddErrorMessage(result.Errors.FirstOrDefault()); } } }
protected void LogIn(object sender, EventArgs e) { if (IsValid) { // Validate the user password IAuthenticationManager manager = new AuthenticationIdentityManager(new IdentityStore()).Authentication; IdentityResult result = manager.CheckPasswordAndSignIn(Context.GetOwinContext().Authentication, UserName.Text, Password.Text, RememberMe.Checked); if (result.Success) { OpenAuthProviders.RedirectToReturnUrl("~/library-system/Default.aspx", Response); } else { FailureText.Text = result.Errors.FirstOrDefault(); ErrorMessage.Visible = true; } } }
protected void LogIn(object sender, EventArgs e) { if (IsValid) { // Validate the user password IAuthenticationManager manager = new AuthenticationIdentityManager(new IdentityStore()).Authentication; IdentityResult result = manager.CheckPasswordAndSignIn(Context.GetOwinContext().Authentication, UserName.Text, Password.Text, RememberMe.Checked); if (result.Success) { OpenAuthProviders.RedirectToReturnUrl("~/library-system/Default.aspx", Response); } else { FailureText.Text = result.Errors.FirstOrDefault(); ErrorMessage.Visible = true; } } }
protected void LogIn(object sender, EventArgs e) { if (this.IsValid) { // Validate the user password IAuthenticationManager manager = new AuthenticationIdentityManager(new IdentityStore(new BooksLibrarySystemContext())).Authentication; IdentityResult result = manager.CheckPasswordAndSignIn(this.Context.GetOwinContext().Authentication, this.UserName.Text, this.Password.Text, this.RememberMe.Checked); if (result.Success) { this.Response.Redirect(this.Request.QueryString["ReturnUrl"], false); //OpenAuthProviders.RedirectToReturnUrl(this.Request.QueryString["ReturnUrl"], this.Response); } else { this.FailureText.Text = result.Errors.FirstOrDefault(); this.ErrorMessage.Visible = true; } } }
protected void LogIn(object sender, EventArgs e) { if (this.IsValid) { // Validate the user password IAuthenticationManager manager = new AuthenticationIdentityManager(new IdentityStore(new BooksLibrarySystemContext())).Authentication; IdentityResult result = manager.CheckPasswordAndSignIn(this.Context.GetOwinContext().Authentication, this.UserName.Text, this.Password.Text, this.RememberMe.Checked); if (result.Success) { this.Response.Redirect(this.Request.QueryString["ReturnUrl"], false); //OpenAuthProviders.RedirectToReturnUrl(this.Request.QueryString["ReturnUrl"], this.Response); } else { this.FailureText.Text = result.Errors.FirstOrDefault(); this.ErrorMessage.Visible = true; } } }
protected void LogIn(object sender, EventArgs e) { if (IsValid) { bool error = false; string username = this.UserName.Text; if (username == "") { ErrorSuccessNotifier.AddErrorMessage("The username field is required"); error = true; } string password = this.Password.Text; if (password == "") { ErrorSuccessNotifier.AddErrorMessage("The password field is required"); error = true; } if (error) { return; } // Validate the user password IAuthenticationManager manager = new AuthenticationIdentityManager(new IdentityStore()).Authentication; IdentityResult result = manager.CheckPasswordAndSignIn(Context.GetOwinContext().Authentication, UserName.Text, Password.Text, RememberMe.Checked); if (result.Success) { OpenAuthProviders.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response); } else { FailureText.Text = result.Errors.FirstOrDefault(); ErrorMessage.Visible = true; } } }
protected void LogIn(object sender, EventArgs e) { if (IsValid) { // Validate the user password IAuthenticationManager manager = new AuthenticationIdentityManager(new IdentityStore(new ApplicationDbContext())).Authentication; IdentityResult result = manager.CheckPasswordAndSignIn(Context.GetOwinContext().Authentication, UserName.Text, Password.Text, RememberMe.Checked); if (result.Success) { ErrorSuccessNotifier.AddSuccessMessage("Welcome back."); ErrorSuccessNotifier.ShowAfterRedirect = true; OpenAuthProviders.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response); } else { //FailureText.Text = result.Errors.FirstOrDefault(); //ErrorMessage.Visible = true; ErrorSuccessNotifier.AddErrorMessage("Login details are incorect."); //ErrorSuccessNotifier.ShowAfterRedirect = true; } } }