public async Task <ActionResult> VerifyPhoneNumber(VerifyPhoneNumberViewModel model) { var Helper = new UserNotificationsHelper(); ViewBag.Notifications = Helper.filterNotifications(User.Identity.GetUserId()); if (!ModelState.IsValid) { return(View(model)); } var result = await UserManager.ChangePhoneNumberAsync(User.Identity.GetUserId(), model.PhoneNumber, model.Code); if (result.Succeeded) { var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); if (user != null) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); } return(RedirectToAction("Index", new { Message = ManageMessageId.AddPhoneSuccess })); } // If we got this far, something failed, redisplay form ModelState.AddModelError("", "Failed to verify phone"); return(View(model)); }
// GET: TicketNotifications/Create public ActionResult Create(int? id) { var Helper = new UserNotificationsHelper(); ViewBag.Notifications = Helper.filterNotifications(User.Identity.GetUserId()); TicketNotification ticketN = db.TicketNotifications.Find(id); return View(ticketN); }
public ActionResult ResendEmailConfirmationSuccess() { var Helper = new UserNotificationsHelper(); ViewBag.Notifications = Helper.filterNotifications(User.Identity.GetUserId()); return(View()); }
// // GET: /Manage/SetPassword public ActionResult SetPassword() { var Helper = new UserNotificationsHelper(); ViewBag.Notifications = Helper.filterNotifications(User.Identity.GetUserId()); return(View()); }
// GET: Tickets/Details/5 public ActionResult Details(int?id) { var Helper = new UserNotificationsHelper(); ViewBag.Notifications = Helper.filterNotifications(User.Identity.GetUserId()); var aHelper = new UserHelper(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var ticket = db.Tickets.Find((int)id); if (ticket == null) { return(HttpNotFound()); } foreach (var notif in ticket.TicketNotifications) { notif.Read = true; } db.Entry(ticket).State = EntityState.Modified; db.SaveChanges(); return(View(ticket)); }
public async Task <ActionResult> ResetPassword(ResetPasswordViewModel model) { var Helper = new UserNotificationsHelper(); ViewBag.Notifications = Helper.filterNotifications(User.Identity.GetUserId()); if (!ModelState.IsValid) { return(View(model)); } var user = await UserManager.FindByNameAsync(model.Email); if (user == null) { // Don't reveal that the user does not exist return(RedirectToAction("ResetPasswordConfirmation", "Account")); } var result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password); if (result.Succeeded) { return(RedirectToAction("ResetPasswordConfirmation", "Account")); } AddErrors(result); return(View()); }
public ActionResult Submitter() { var nHelper = new UserNotificationsHelper(); ViewBag.Notifications = nHelper.filterNotifications(User.Identity.GetUserId()); userListViewModel zthings = new userListViewModel(); var list = new List <string>(); var list1 = new List <ApplicationUser>(); var list2 = new List <string>(); var users = db.Users.ToList(); foreach (var user in users) { list1.Add(user); var roles = user.Roles; list.Clear(); foreach (var role in roles) { var zRole = db.Roles.Find(role.RoleId); list.Add(zRole.Name); } list.Sort(); list2.Add(string.Join(", ", list)); } zthings.Person = list1; zthings.userRoles = list2; ViewBag.usernrole = zthings.Person.Zip(zthings.userRoles, (p, u) => new { zUser = p, zRole = u }); return(View(zthings)); }
public ActionResult ResetPassword(string code) { var Helper = new UserNotificationsHelper(); ViewBag.Notifications = Helper.filterNotifications(User.Identity.GetUserId()); return(code == null?View("Error") : View()); }
// GET: Tickets/Edit/5 public ActionResult Edit(int?id) { var nHelper = new UserNotificationsHelper(); ViewBag.Notifications = nHelper.filterNotifications(User.Identity.GetUserId()); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var tHelper = new UserHelper(); Ticket ticket = tHelper.FindTicket((int)id); if (ticket == null) { return(HttpNotFound()); } TempData["Ticket"] = ticket; var rHelper = new UserRolesHelper(); ViewBag.AssignedToUserId = new SelectList(rHelper.UsersInRole("Developer"), "Id", "FirstName", ticket.AssignedToUserId); ViewBag.ProjectId = new SelectList(db.Projects, "Id", "Name", ticket.ProjectId); ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name", ticket.TicketPriorityId); ViewBag.TicketStatusId = new SelectList(db.TicketStatuses, "Id", "Name", ticket.TicketStatusId); ViewBag.TicketTypeId = new SelectList(db.TicketTypes, "Id", "Name", ticket.TicketTypeId); return(View(ticket)); }
public async Task <ActionResult> SetPassword(SetPasswordViewModel model) { var Helper = new UserNotificationsHelper(); ViewBag.Notifications = Helper.filterNotifications(User.Identity.GetUserId()); if (ModelState.IsValid) { var result = await UserManager.AddPasswordAsync(User.Identity.GetUserId(), model.NewPassword); if (result.Succeeded) { var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); if (user != null) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); } return(RedirectToAction("Index", new { Message = ManageMessageId.SetPasswordSuccess })); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
// GET: TicketTypes public ActionResult Index() { var nHelper = new UserNotificationsHelper(); ViewBag.Notifications = nHelper.filterNotifications(User.Identity.GetUserId()); return(View(db.TicketTypes.ToList())); }
// GET: TicketTypes/Create public ActionResult Create() { var nHelper = new UserNotificationsHelper(); ViewBag.Notifications = nHelper.filterNotifications(User.Identity.GetUserId()); return(View()); }
public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model) { var Helper = new UserNotificationsHelper(); ViewBag.Notifications = Helper.filterNotifications(User.Identity.GetUserId()); if (ModelState.IsValid) { var user = await UserManager.FindByNameAsync(model.Email); if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id))) { // Don't reveal that the user does not exist or is not confirmed return(View("ForgotPasswordConfirmation")); } // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id); var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); await UserManager.SendEmailAsync(user.Id, "Reset Password", "Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("ForgotPasswordConfirmation", "Account")); } // If we got this far, something failed, redisplay form return(View(model)); }
// // GET: /Manage/Index public async Task <ActionResult> Index(ManageMessageId?message) { var Helper = new UserNotificationsHelper(); ViewBag.Notifications = Helper.filterNotifications(User.Identity.GetUserId()); ViewBag.StatusMessage = message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed." : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set." : message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set." : message == ManageMessageId.Error ? "An error has occurred." : message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added." : message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed." : ""; var userId = User.Identity.GetUserId(); var model = new IndexViewModel { HasPassword = HasPassword(), PhoneNumber = await UserManager.GetPhoneNumberAsync(userId), TwoFactor = await UserManager.GetTwoFactorEnabledAsync(userId), Logins = await UserManager.GetLoginsAsync(userId), BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId) }; return(View(model)); }
// // GET: /Manage/ManageLogins public async Task <ActionResult> ManageLogins(ManageMessageId?message) { var Helper = new UserNotificationsHelper(); ViewBag.Notifications = Helper.filterNotifications(User.Identity.GetUserId()); ViewBag.StatusMessage = message == ManageMessageId.RemoveLoginSuccess ? "The external login was removed." : message == ManageMessageId.Error ? "An error has occurred." : ""; var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); if (user == null) { return(View("Error")); } var userLogins = await UserManager.GetLoginsAsync(User.Identity.GetUserId()); var otherLogins = AuthenticationManager.GetExternalAuthenticationTypes().Where(auth => userLogins.All(ul => auth.AuthenticationType != ul.LoginProvider)).ToList(); ViewBag.ShowRemoveButton = user.PasswordHash != null || userLogins.Count > 1; return(View(new ManageLoginsViewModel { CurrentLogins = userLogins, OtherLogins = otherLogins })); }
public async Task <ActionResult> Index(LoginViewModel model, string returnUrl) { var Helper = new UserNotificationsHelper(); ViewBag.Notifications = Helper.filterNotifications(User.Identity.GetUserId()); ApplicationDbContext db = new ApplicationDbContext(); ViewBag.Roles = new SelectList(db.Roles, "Id", "Name"); if (!ModelState.IsValid) { return(View(model)); } // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout : false); switch (result) { case SignInStatus.Success: return(RedirectToLocal(returnUrl)); case SignInStatus.LockedOut: return(View("Lockout")); case SignInStatus.RequiresVerification: return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe })); case SignInStatus.Failure: default: ModelState.AddModelError("", "Invalid login attempt."); return(View(model)); } }
public async Task <ActionResult> VerifyCode(VerifyCodeViewModel model) { var Helper = new UserNotificationsHelper(); ViewBag.Notifications = Helper.filterNotifications(User.Identity.GetUserId()); if (!ModelState.IsValid) { return(View(model)); } // The following code protects for brute force attacks against the two factor codes. // If a user enters incorrect codes for a specified amount of time then the user account // will be locked out for a specified amount of time. // You can configure the account lockout settings in IdentityConfig var result = await SignInManager.TwoFactorSignInAsync(model.Provider, model.Code, isPersistent : model.RememberMe, rememberBrowser : model.RememberBrowser); switch (result) { case SignInStatus.Success: return(RedirectToLocal(model.ReturnUrl)); case SignInStatus.LockedOut: return(View("Lockout")); case SignInStatus.Failure: default: ModelState.AddModelError("", "Invalid code."); return(View(model)); } }
public ActionResult LinkLogin(string provider) { var Helper = new UserNotificationsHelper(); ViewBag.Notifications = Helper.filterNotifications(User.Identity.GetUserId()); // Request a redirect to the external login provider to link a login for the current user return(new AccountController.ChallengeResult(provider, Url.Action("LinkLoginCallback", "Manage"), User.Identity.GetUserId())); }
// GET: TicketHistories/Create public ActionResult Create() { var nHelper = new UserNotificationsHelper(); ViewBag.Notifications = nHelper.filterNotifications(User.Identity.GetUserId()); ViewBag.TicketId = new SelectList(db.Tickets, "Id", "Title"); return(View()); }
// GET: TicketHistories public ActionResult Index() { var nHelper = new UserNotificationsHelper(); ViewBag.Notifications = nHelper.filterNotifications(User.Identity.GetUserId()); var ticketHistories = db.TicketHistories.Include(t => t.Ticket); return(View(ticketHistories.ToList())); }
public ActionResult DeleteConfirmed(int id) { var Helper = new UserNotificationsHelper(); ViewBag.Notifications = Helper.filterNotifications(User.Identity.GetUserId()); TicketNotification ticketNotification = db.TicketNotifications.Find(id); db.TicketNotifications.Remove(ticketNotification); db.SaveChanges(); return RedirectToAction("Index"); }
public ActionResult Contact() { var Helper = new UserNotificationsHelper(); ViewBag.Notifications = Helper.filterNotifications(User.Identity.GetUserId()); ViewBag.Message = "Your contact page."; return(View()); }
public ActionResult About() { var Helper = new UserNotificationsHelper(); ViewBag.Notifications = Helper.filterNotifications(User.Identity.GetUserId()); ViewBag.Message = "Your application description page."; return(View()); }
public ActionResult DeleteConfirmed(int id) { var nHelper = new UserNotificationsHelper(); ViewBag.Notifications = nHelper.filterNotifications(User.Identity.GetUserId()); Project project = db.Projects.Find(id); db.Projects.Remove(project); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Index(string returnUrl) { var nHelper = new UserNotificationsHelper(); ViewBag.Notifications = nHelper.filterNotifications(User.Identity.GetUserId()); ApplicationDbContext db = new ApplicationDbContext(); ViewBag.Roles = new SelectList(db.Roles, "Id", "Name"); ViewBag.ReturnUrl = returnUrl; return(View()); }
public ActionResult DeleteConfirmed(int id) { var nHelper = new UserNotificationsHelper(); ViewBag.Notifications = nHelper.filterNotifications(User.Identity.GetUserId()); var tHelper = new UserHelper(); Ticket ticket = tHelper.FindTicket((int)id); tHelper.RemoveFromTicket(ticket); return(RedirectToAction("Index")); }
// GET: TicketNotifications public ActionResult Index() { var Helper = new UserNotificationsHelper(); ViewBag.Notifications = Helper.filterNotifications(User.Identity.GetUserId()); List<TicketNotification> listTN = new List<TicketNotification>(); foreach (var tn in db.TicketNotifications) { if(tn.UserId == User.Identity.GetUserId()) { listTN.Add(tn);} } return View(listTN.ToList()); }
public async Task <ActionResult> ConfirmEmail(string userId, string code) { var Helper = new UserNotificationsHelper(); ViewBag.Notifications = Helper.filterNotifications(User.Identity.GetUserId()); if (userId == null || code == null) { return(View("Error")); } var result = await UserManager.ConfirmEmailAsync(userId, code); return(View(result.Succeeded ? "ConfirmEmail" : "Error")); }
public ActionResult Edit([Bind(Include = "Id,Name")] TicketType ticketType) { var nHelper = new UserNotificationsHelper(); ViewBag.Notifications = nHelper.filterNotifications(User.Identity.GetUserId()); if (ModelState.IsValid) { db.Entry(ticketType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(ticketType)); }
public ActionResult Edit([Bind(Include = "Id,TicketId,UserId,Notice,Read")] TicketNotification ticketNotification) { var Helper = new UserNotificationsHelper(); ViewBag.Notifications = Helper.filterNotifications(User.Identity.GetUserId()); if (ModelState.IsValid) { db.Entry(ticketNotification).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.TicketId = new SelectList(db.Tickets, "Id", "Title", ticketNotification.TicketId); return View(ticketNotification); }