//Need styling public ActionResult ListAccounts() { AccountRepo accounts = new AccountRepo(); return View(accounts.GetAllAccounts()); }
public ActionResult Register(RegisteredUser newUser) { CaptchaHelper captchaHelper = new CaptchaHelper(); string captchaResponse = captchaHelper.CheckRecaptcha(); if (captchaResponse != "Valid") { ViewBag.ErrorResponse = "The captcha must be valid"; return View(); } var userStore = new UserStore<IdentityUser>(); UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore) { UserLockoutEnabledByDefault = true, DefaultAccountLockoutTimeSpan = new TimeSpan(0, 10, 0), MaxFailedAccessAttemptsBeforeLockout = 3 }; var identityUser = new IdentityUser() { UserName = newUser.UserName, Email = newUser.Email }; IdentityResult result = manager.Create(identityUser, newUser.Password); if (result.Succeeded) { if (newUser.UserRole.Equals("Buyer") || newUser.UserRole.Equals("Farm")) { //Taking the username on the account successful creation and applying it to the //Farm database to create a Farm table with that username under the 'farmName' field. AccountRepo accountRepo = new AccountRepo(); accountRepo.InitializeUserAccount(newUser); } var authenticationManager = HttpContext.Request.GetOwinContext().Authentication; var userIdentity = manager.CreateIdentity(identityUser, DefaultAuthenticationTypes.ApplicationCookie); authenticationManager.SignIn(new AuthenticationProperties() { }, userIdentity); string testVariable = newUser.UserRole; AddUserToRole(newUser.UserName, newUser.UserRole); CreateTokenProvider(manager, EMAIL_CONFIRMATION); var code = manager.GenerateEmailConfirmationToken(identityUser.Id); var callbackUrl = Url.Action("ConfirmEmail", "Home", new { userId = identityUser.Id, code = code }, protocol: Request.Url.Scheme); string emailMessage = "Please confirm your account by clicking this link: <a href=\"" + callbackUrl + "\">Confirm Registration</a>"; string response = new MailHelper().EmailFromArvixe(new ViewModels.Message(newUser.Email, emailMessage)); ViewBag.ConfirmationResponse = response; TempData["ConfirmationResponse"] = "You have successfully registered for an account. Please verify your account by clicking on the link sent to you in your e-mail."; return RedirectToAction("Login"); } ViewBag.ErrorResponse = "There was an error with the input provided"; return View(); }
//Have to delete all child tables that have the userID tied to it first. //NEED TO FIX THE REMOVE ACCOUNT FUNCTION IN ACCOUNT REPO public ActionResult DeleteAccount(int id) { AccountRepo accounts = new AccountRepo(); accounts.RemoveAccount(id); return RedirectToAction("ListAccounts"); }