Пример #1
0
        /// <summary>
        /// Register a new user and send an email with the login information.
        /// </summary>
        /// <param name="username"></param>
        /// <param name="emailAddress"></param>
        public void RegisterUser(string username, string emailAddress)
        {
            Site currentSite = this.Section.Node.Site;
            // Create user
            string newPassword = this._userService.CreateUser(username, emailAddress, currentSite);

            // Send email
            this._emailService.Language = base.Section.Node.Culture.Substring(0, 2);
            Dictionary <string, string> subjectParams = new Dictionary <string, string>(1);

            subjectParams.Add("$site", currentSite.Name);
            Dictionary <string, string> bodyParams = new Dictionary <string, string>(3);

            bodyParams.Add("$site", currentSite.Name);
            bodyParams.Add("$username", username);
            bodyParams.Add("$password", newPassword);

            try
            {
                this._emailService.ProcessEmail(currentSite.WebmasterEmail, emailAddress, "Register", subjectParams, bodyParams);
            }
            catch
            {
                // Delete newly created user when emailing account info fails.
                Cuyahoga.Core.Domain.User newUser = this._userService.GetUserByUsernameAndEmail(username, emailAddress);
                if (newUser != null)
                {
                    this._userService.DeleteUser(newUser);
                }
                throw;
            }
        }
Пример #2
0
 /// <summary>
 /// Update an exising user.
 /// </summary>
 /// <param name="user"></param>
 public void UpdateUser(Cuyahoga.Core.Domain.User user)
 {
     // Save to database
     this._userService.UpdateUser(user);
     // Remove old user instance from the cache
     HttpContext.Current.Cache.Remove(userCacheKeyPrefix + user.Id.ToString());
 }