public ActionResult AcceptInvitation(string id) { ViewBag.ItemsEnable = _command; if (string.IsNullOrEmpty(id)) { return(new HttpNotFoundResult()); } var invitationModel = _invitationUILogic.GetInvitationModelByModelId(id); if (invitationModel == null) { return(new HttpNotFoundResult()); } else if (invitationModel.Status == InvitationStatus.Rejected || invitationModel.Status == InvitationStatus.Active) { return(RedirectToAction("Login", "Account")); } ActionResult redirectToRoute; return(this.RedirectToCorrectTenancy(invitationModel, out redirectToRoute) ? redirectToRoute : this.View(invitationModel)); }
public ActionResult AuthenticationInviteCode(AuthenticationInviteCodeModel model) { if (!ModelState.IsValid) { return(this.View(model)); } if (string.IsNullOrEmpty(model.AuthenticationCode)) { ModelState.AddModelError("AuthenticationCode", "The code is required"); } else { var invitationLogic = new InvitationUILogic(); var invitation = invitationLogic.GetInvitationModelByModelId(model.AuthenticationCode); if (invitation == null) { ModelState.AddModelError("AuthenticationCode", "Code is invalid"); } else { if (invitation.Tenancy.Equals(TenantManager.CurrentTenancy, StringComparison.OrdinalIgnoreCase) || !User.Identity.IsAuthenticated) { return(this.RedirectToRoute( "Default", new { tenant = invitation.Tenancy, controller = "OwnerInvitation", areaName = Areas.UserManagementUI.AreaPortableName.AreaName, action = "AcceptInvitation", id = invitation.AuthorizationCode //.UrlEncodedCode })); } FormsAuthentication.SignOut(); this.SetAuthCookie(User.Identity.Name, false, invitation.Tenancy); return(this.RedirectToRoute( "Default", new { tenant = invitation.Tenancy, controller = "OwnerInvitation", areaName = Areas.UserManagementUI.AreaPortableName.AreaName, action = "AcceptInvitation", id = invitation.AuthorizationCode //.UrlEncodedCode })); } } return(this.View(model)); }
public ActionResult Register(RegisterModel model) { try { if (ModelState.IsValid) { //begin var invitationUILogic = new InvitationUILogic(); var invitationModel = invitationUILogic.GetInvitationModelByModelId(model.AuthenticationCode); if (invitationModel == null && !TenantManager.CurrentTenancy.Equals( Tenants.SuperAdmin, StringComparison.InvariantCultureIgnoreCase)) { ModelState.AddModelError("AuthenticationCode", "Code is invalid"); ViewBag.ErrorMessage = "Code is invalid"; return(View(model)); } if (invitationModel != null) { ActionResult redirectToRoute; if (this.RedirectToCorrectTenancy(invitationModel, out redirectToRoute)) { return(redirectToRoute); } if (!invitationModel.SentTo.Equals(model.Email, StringComparison.InvariantCultureIgnoreCase)) { this.ModelState.AddModelError("Email", "Email do not equals invitation's email"); ViewBag.ErrorMessage = "Email do not equals invitation's email"; return(View(model)); } } //end var invitation = this.Session["Invitation"] as OwnerInvitationModel ?? invitationModel; Server.MapPath(DefaultAvatarLocation); MembershipCreateStatus createStatus; //membership created and log automatically if (CreateMembershipUser(model, invitationUILogic.ModelToEntity(invitation), out createStatus)) { Session["Invitation"] = null; object passcode; string code = null; if (TempData.TryGetValue("passcode", out passcode)) { code = passcode.ToString(); } //if (code != null) if (!string.IsNullOrEmpty(code)) { TempData.Remove("passcode"); var passCodeModel = new TakeOwnerShipModel { PassCode = code }; if (_accountBusinessLogic.AddRoleToUser(passCodeModel, User.Identity.Name)) { var user = User as ApplicationUser; if (user != null && user.Tenancy.Equals(Tenants.SuperAdmin, StringComparison.InvariantCultureIgnoreCase)) { return(RedirectToAction("Index", "OwnerInvitation")); } ActionResult redirectToRoute; return(this.LoginPostValidations(out redirectToRoute) ? redirectToRoute : RedirectAfterLogin(null)); } } } this.ModelState.AddModelError(string.Empty, ErrorCodeToString(createStatus)); } } catch (Exception ex) { if (ExceptionHandler.Manage(ex, this, Layer.UILogic)) { this.ModelState.AddModelError(string.Empty, ex.Message); ViewBag.ErrorMessage = ex.Message; } else { if (ex.InnerException != null) { _log.ErrorFormat("{0} \n Inner Exception: {1}", ex, ex.InnerException); } else { _log.ErrorFormat("An exception occurred with the following message: {0}", ex.Message); } _applicationAlert.RaiseAlert(ApplicationAlertKind.System, ex.TraceInformation()); const string errorMessage = "An error occurred while processing your request. Please refresh the page. The error have been logged."; this.ModelState.AddModelError(string.Empty, errorMessage); ViewBag.ErrorMessage = errorMessage; } return(View(model)); } // If we got this far, something failed, redisplay form //return View(model);S ActionResult routeToRedirect; return(this.LoginPostValidations(out routeToRedirect) ? routeToRedirect : RedirectAfterLogin(null)); //return RedirectToAction("Index", "OwnerInvitation"); }