public static ActionResult CreateUser(RegisterDetails RegisterDetails) { ActionResult actionResult = new ActionResult(); User.Membership.Approved = PortalSettings.Current.UserRegistration == (int)Globals.PortalRegistrationType.PublicRegistration; CreateStatus = UserController.CreateUser(ref User); DataCache.ClearPortalUserCountCache(PortalSettings.Current.PortalId); try { if (CreateStatus == UserCreateStatus.Success) { ////Assocate alternate Login with User and proceed with Login //if (!String.IsNullOrEmpty(AuthenticationType)) //{ // AuthenticationController.AddUserAuthentication(User.UserID, AuthenticationType, UserToken); //} ActionResult result = CompleteUserCreation(CreateStatus, User, true, !(HttpContext.Current.Request.IsAuthenticated && PortalSecurity.IsInRole(PortalSettings.Current.AdministratorRoleName)) && !(HttpContext.Current.Request.IsAuthenticated && (User.UserID == (PortalController.Instance.GetCurrentSettings() as PortalSettings).UserInfo.UserID))); if (result.IsSuccess) { if (string.IsNullOrEmpty(result.Message)) { IDictionary <string, object> dynObjects = new ExpandoObject() as IDictionary <string, object>; dynObjects.Add("RedirectURL", GetRedirectUrl()); actionResult.Data = dynObjects; } actionResult.Message = result.Message; } else { string errorMessage = string.Empty; foreach (KeyValuePair <string, Exception> error in result.Errors) { errorMessage = error.Value.ToString(); } actionResult.AddError("RegisterManager.CompleteUserCreation", errorMessage); } } else { actionResult.AddError("RegisterManager.CreateUser", UserController.GetUserCreateStatus(CreateStatus)); } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(null, exc); } return(actionResult); }
/// ----------------------------------------------------------------------------- /// <summary> /// cmdUpdate_Click runs when the Update Button is clicked. /// </summary> private void cmdUpdate_Click(object sender, EventArgs e) { if (this.IsUserOrAdmin == false) { return; } if (this.AddUser) { if (this.IsValid) { this.CreateUser(); DataCache.ClearPortalUserCountCache(this.PortalId); } } else { if (this.userForm.IsValid && (this.User != null)) { if (this.User.UserID == this.PortalSettings.AdministratorId) { // Clear the Portal Cache DataCache.ClearPortalUserCountCache(this.UserPortalID); } try { // Update DisplayName to conform to Format this.UpdateDisplayName(); // either update the username or update the user details if (this.CanUpdateUsername() && !this.PortalSettings.Registration.UseEmailAsUserName) { UserController.ChangeUsername(this.User.UserID, this.renameUserName.Value.ToString()); } // DNN-5874 Check if unique display name is required if (this.PortalSettings.Registration.RequireUniqueDisplayName) { var usersWithSameDisplayName = (System.Collections.Generic.List <UserInfo>)MembershipProvider.Instance().GetUsersBasicSearch(this.PortalId, 0, 2, "DisplayName", true, "DisplayName", this.User.DisplayName); if (usersWithSameDisplayName.Any(user => user.UserID != this.User.UserID)) { UI.Skins.Skin.AddModuleMessage(this, this.LocalizeString("DisplayNameNotUnique"), UI.Skins.Controls.ModuleMessage.ModuleMessageType.RedError); return; } } UserController.UpdateUser(this.UserPortalID, this.User); if (this.PortalSettings.Registration.UseEmailAsUserName && (this.User.Username.ToLower() != this.User.Email.ToLower())) { UserController.ChangeUsername(this.User.UserID, this.User.Email); } this.OnUserUpdated(EventArgs.Empty); this.OnUserUpdateCompleted(EventArgs.Empty); } catch (Exception exc) { Logger.Error(exc); var args = new UserUpdateErrorArgs(this.User.UserID, this.User.Username, "EmailError"); this.OnUserUpdateError(args); } } } }