public UserAccountWithMappingData(UserAccount accountData, UserMappingData mappingData) { PrincipalID = accountData.PrincipalID; FirstName = accountData.FirstName; LastName = accountData.LastName; Email = accountData.Email; ScopeID = accountData.ScopeID; UserLevel = accountData.UserLevel; UserFlags = accountData.UserFlags; UserTitle = accountData.UserTitle; ServiceURLs = accountData.ServiceURLs; Created = accountData.Created; if (mappingData != null) { RealFirstName = mappingData.RealFirstName; RealLastName = mappingData.RealLastName; Institution = mappingData.Institution; ConnectID = mappingData.ConnectID; } else { RealFirstName = string.Empty; RealLastName = string.Empty; Institution = string.Empty; ConnectID = string.Empty; } }
public string NewAccountPostRequest(Environment env, string first, string last, string email, string password, string password2, string avatarType, string institution = "", string realFirst = "", string realLast = "", string connectID = "") { if (!m_WebApp.IsInstalled) { m_log.DebugFormat("[Wifi]: warning: someone is trying to access NewAccountPostRequest and Wifi isn't installed!"); return m_WebApp.ReadFile(env, "index.html"); } m_log.DebugFormat("[Wifi]: NewAccountPostRequest"); Request request = env.Request; // Validate data first = first.Trim(); last = last.Trim(); institution = institution.Trim(); realFirst = realFirst.Trim(); realLast = realLast.Trim(); List<string> errorList = ValidateFormData(first, last, email, password, password2, institution, realFirst, realLast); // Create account if there are no errors with the form input if (errorList.Count == 0) { UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, first, last); if (account == null) account = m_UserAccountService.GetUserAccount(UUID.Zero, m_PendingIdentifier + first, last); if (account == null) { Dictionary<string, object> urls = new Dictionary<string, object>(); if (m_WebApp.AccountConfirmationRequired) { //attach pending identifier to first name first = m_PendingIdentifier + first; // Store the password temporarily here urls["Password"] = password; urls["Avatar"] = avatarType; if (env.LanguageInfo != null) urls["Language"] = Localization.LanguageInfoToString(env.LanguageInfo); } // Create the account account = new UserAccount(UUID.Zero, first, last, email); account.ServiceURLs = urls; account.UserTitle = "Local User"; m_UserAccountService.StoreUserAccount(account); // Create the account mapping UserMappingData accMapping = new UserMappingData(); accMapping.ConnectID = connectID; accMapping.PrincipalID = account.PrincipalID; accMapping.RealFirstName = realFirst; accMapping.RealLastName = realLast; accMapping.Institution = institution; m_UserAccountService.StoreUserMapping(accMapping); string notification = _("Your account has been created.", env); if (!m_WebApp.AccountConfirmationRequired) { // Create the inventory m_InventoryService.CreateUserInventory(account.PrincipalID); // Store the password m_AuthenticationService.SetPassword(account.PrincipalID, password); // Set avatar SetAvatar(env, account.PrincipalID, avatarType); } else if (m_WebApp.AdminEmail != string.Empty) { string message = string.Format( _("New account {0} {1} created in {2} is awaiting your approval.", m_WebApp.AdminLanguage), first, last, m_WebApp.GridName); message += string.Format("\n\nReal Name: {0} {1}", realFirst, realLast); message += string.Format("\nEmail: {0}", email); message += string.Format("\nInstitution: {0}", institution); message += "\n\n" + m_WebApp.WebAddress + "/wifi"; SendEMail( m_WebApp.AdminEmail, _("Account awaiting approval", m_WebApp.AdminLanguage), message); notification = _("Your account awaits administrator approval.", env); } NotifyWithoutButton(env, notification); m_log.DebugFormat("[Wifi]: Created account for user {0}", account.Name); } else { m_log.DebugFormat("[Wifi]: Attempt at creating an account that already exists"); env.State = State.NewAccountForm; env.Data = GetDefaultAvatarSelectionList(); } } else { m_log.DebugFormat("[Wifi]: did not create account because of form field problems"); env.State = State.NewAccountForm; env.Data = GetDefaultAvatarSelectionList(); if (errorList.Count > 0) { m_WebApp.PostError = @"<div class=""error"">The following problems occurred:<ul>"; foreach (string error in errorList) { m_WebApp.PostError += string.Format("<li>{0}</li>", error); } m_WebApp.PostError += "</ul></div>"; } if (m_WebApp.PostFirst == string.Empty) { m_WebApp.PostFirst = first; } if (m_WebApp.PostLast == string.Empty) { m_WebApp.PostLast = last; } if (m_WebApp.PostEmail == string.Empty) { m_WebApp.PostEmail = email; } m_WebApp.PostRealFirst = realFirst; m_WebApp.PostRealLast = realLast; m_WebApp.PostInstitution = institution; } return m_WebApp.ReadFile(env, "index.html"); }
public bool StoreUserMapping(UserMappingData data) { // Store the account mapping return m_Database2.Store(data); }