private bool Register() { //Try // Only attempt a save/update if all form fields on the page are valid if (Page.IsValid) { // check required fields int UID = -1; // Dim userCreateStatus As UserCreateStatus = userCreateStatus.AddUser UserInfo objUserInfo = UserController.GetUserByName(PortalId, atiSlimControl.Email, false); // if a user is found with that username, error. // this prevents you from adding a username // with the same name as a superuser. if (objUserInfo != null) { lErrorText.Text = "We already have an entry for the User Name."; return(false); } UserInfo objNewUser = InitialiseUser(); // TODO: this method int affiliateId = 0; if (Request.Cookies["AffiliateId"] != null) { affiliateId = Convert.ToInt32(Request.Cookies["AffiliateId"]); } objNewUser.PortalID = PortalId; objNewUser.Profile.FirstName = atiSlimControl.FirstName; objNewUser.Profile.LastName = atiSlimControl.LastName; objNewUser.FirstName = objNewUser.Profile.FirstName; objNewUser.LastName = objNewUser.Profile.LastName; objNewUser.DisplayName = atiSlimControl.Email; objNewUser.Profile.Unit = string.Empty; objNewUser.Profile.Street = string.Empty; objNewUser.Profile.City = string.Empty; objNewUser.Profile.Region = string.Empty; objNewUser.Profile.PostalCode = string.Empty; objNewUser.Profile.Country = string.Empty; objNewUser.Email = atiSlimControl.Email; objNewUser.Username = atiSlimControl.UserName; objNewUser.Membership.Password = atiSlimControl.Password; objNewUser.Membership.Approved = true; // Convert.ToBoolean((PortalSettings.UserRegistration != PortalRegistrationType.PublicRegistration ? false : true)); objNewUser.AffiliateID = affiliateId; DotNetNuke.Security.Membership.UserCreateStatus userCreateStatus = UserController.CreateUser(ref objNewUser); if (userCreateStatus == DotNetNuke.Security.Membership.UserCreateStatus.Success) { UID = objNewUser.UserID; // DNN3 BUG DotNetNuke.Services.Log.EventLog.EventLogController objEventLog = new DotNetNuke.Services.Log.EventLog.EventLogController(); objEventLog.AddLog(objNewUser, PortalSettings, objNewUser.UserID, atiSlimControl.Email, DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.USER_CREATED); // send notification to portal administrator of new user registration DotNetNuke.Services.Mail.Mail.SendMail(objNewUser, DotNetNuke.Services.Mail.MessageType.UserRegistrationAdmin, PortalSettings); DotNetNuke.Services.Mail.Mail.SendMail(objNewUser, DotNetNuke.Services.Mail.MessageType.UserRegistrationPublic, PortalSettings); if (affiliateId > 0) { DotNetNuke.Services.Vendors.AffiliateController objAffiliates = new DotNetNuke.Services.Vendors.AffiliateController(); objAffiliates.UpdateAffiliateStats(affiliateId, 0, 1); } DataCache.ClearUserCache(PortalId, objNewUser.Username); UserController.UserLogin(PortalId, objNewUser, PortalSettings.PortalName, DotNetNuke.Services.Authentication.AuthenticationLoginBase.GetIPAddress(), true); string body = "<br/>ID: " + objNewUser.UserID; body += "<br/>User: "******"<br/>First Name: " + objNewUser.FirstName; body += "<br/>Last Name: " + objNewUser.LastName; DotNetNuke.Services.Mail.Mail.SendMail("*****@*****.**", "*****@*****.**", "", "NEW aqufit.com USER", body, "", "HTML", "", "", "", ""); } else { // registration error string errStr = userCreateStatus.ToString() + "\n\n" + atiSlimControl.ToString(); DotNetNuke.Services.Mail.Mail.SendMail("*****@*****.**", "*****@*****.**", "", "FAILED REGISTRATION", lErrorText.Text + errStr, "", "HTML", "", "", "", ""); lErrorText.Text = "REGISTRATION ERROR: " + userCreateStatus.ToString(); return(false); } } return(true); }
private bool Register() { //Try // Only attempt a save/update if all form fields on the page are valid if (Page.IsValid) { // check required fields int UID = -1; // Dim userCreateStatus As UserCreateStatus = userCreateStatus.AddUser UserInfo objUserInfo = UserController.GetUserByName(PortalId, atiSlimControl.Email, false); // if a user is found with that username, error. // this prevents you from adding a username // with the same name as a superuser. if (objUserInfo != null) { lErrorText.Text = "We already have an entry for the User Name."; return false; } UserInfo objNewUser = InitialiseUser(); // TODO: this method int affiliateId = 0; if (Request.Cookies["AffiliateId"] != null) { affiliateId = Convert.ToInt32(Request.Cookies["AffiliateId"]); } objNewUser.PortalID = PortalId; objNewUser.Profile.FirstName = atiSlimControl.FirstName; objNewUser.Profile.LastName = atiSlimControl.LastName; objNewUser.FirstName = objNewUser.Profile.FirstName; objNewUser.LastName = objNewUser.Profile.LastName; objNewUser.DisplayName = atiSlimControl.Email; objNewUser.Profile.Unit = string.Empty; objNewUser.Profile.Street = string.Empty; objNewUser.Profile.City = string.Empty; objNewUser.Profile.Region = string.Empty; objNewUser.Profile.PostalCode = string.Empty; objNewUser.Profile.Country = string.Empty; objNewUser.Email = atiSlimControl.Email; objNewUser.Username = atiSlimControl.UserName; objNewUser.Membership.Password = atiSlimControl.Password; objNewUser.Membership.Approved = true; // Convert.ToBoolean((PortalSettings.UserRegistration != PortalRegistrationType.PublicRegistration ? false : true)); objNewUser.AffiliateID = affiliateId; DotNetNuke.Security.Membership.UserCreateStatus userCreateStatus = UserController.CreateUser(ref objNewUser); if (userCreateStatus == DotNetNuke.Security.Membership.UserCreateStatus.Success) { UID = objNewUser.UserID; // DNN3 BUG DotNetNuke.Services.Log.EventLog.EventLogController objEventLog = new DotNetNuke.Services.Log.EventLog.EventLogController(); objEventLog.AddLog(objNewUser, PortalSettings, objNewUser.UserID, atiSlimControl.Email, DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.USER_CREATED); // send notification to portal administrator of new user registration DotNetNuke.Services.Mail.Mail.SendMail(objNewUser, DotNetNuke.Services.Mail.MessageType.UserRegistrationAdmin, PortalSettings); DotNetNuke.Services.Mail.Mail.SendMail(objNewUser, DotNetNuke.Services.Mail.MessageType.UserRegistrationPublic, PortalSettings); if (affiliateId > 0) { DotNetNuke.Services.Vendors.AffiliateController objAffiliates = new DotNetNuke.Services.Vendors.AffiliateController(); objAffiliates.UpdateAffiliateStats(affiliateId, 0, 1); } DataCache.ClearUserCache(PortalId, objNewUser.Username); UserController.UserLogin(PortalId, objNewUser, PortalSettings.PortalName, DotNetNuke.Services.Authentication.AuthenticationLoginBase.GetIPAddress(), true); string body = "<br/>ID: " + objNewUser.UserID; body += "<br/>User: "******"<br/>First Name: " + objNewUser.FirstName; body += "<br/>Last Name: " + objNewUser.LastName; DotNetNuke.Services.Mail.Mail.SendMail("*****@*****.**", "*****@*****.**", "", "NEW aqufit.com USER", body, "", "HTML", "", "", "", ""); } else { // registration error string errStr = userCreateStatus.ToString() + "\n\n" + atiSlimControl.ToString(); DotNetNuke.Services.Mail.Mail.SendMail("*****@*****.**", "*****@*****.**", "", "FAILED REGISTRATION", lErrorText.Text + errStr, "", "HTML", "", "", "", ""); lErrorText.Text = "REGISTRATION ERROR: " + userCreateStatus.ToString(); return false; } } return true; }