Beispiel #1
0
Datei: User.cs Projekt: LByron/BS
        public bool AddUser(string emailAddress, string displayName, string userActivationTicket)
        {
            var status = false;
            var item = _usersTable.SingleOrDefault(u => u.UserEmailAddress == emailAddress);

            if (item == null)
            {
                var user = new UserEntity
                    {
                        UserName = string.Empty,
                        UserDisplayName = displayName,
                        Password = string.Empty,
                        UserCode = string.Empty,
                        UserEmailAddress = emailAddress,
                        UserActiveStatus = null,
                        ActivationKey = userActivationTicket
                    };

                _usersTable.InsertOnSubmit(user);
                context.SubmitChanges();
                status = true;
            }
            else
            {
                if (item.UserID != 1)
                {
                    item.UserDisplayName = displayName;
                    item.ActivationKey = userActivationTicket;
                    context.SubmitChanges();
                    status = true;
                }
            }

            return status;
        }
Beispiel #2
0
        private UserEntity GetUserEntity(UpdateProfileModel model)
        {
            var userEntity = new UserEntity
            {
                UserID = GetUserId(),
                UserDisplayName = model.UserDisplayName,
                UserEmailAddress = model.UserEmailAddress,
                UserSite = model.UserSite
            };

            if (!string.IsNullOrEmpty(model.NewPassword) && !string.IsNullOrEmpty(model.ConfirmPassword))
            {
                var randomCode = RandomStringGenerator.RandomString();
                userEntity.Password = PasswordHelper.GenerateHashedPassword(model.NewPassword, randomCode);
                userEntity.UserCode = TripleDES.EncryptString(randomCode);
            }

            return userEntity;
        }
Beispiel #3
0
 private void UpdatePassword(SetupDefaultParametersViewModel setupDefaultParametersViewModel)
 {
     var randomCode = RandomStringGenerator.RandomString();
     var userEntity = new UserEntity
                          {
                              UserID = 1,
                              Password = PasswordHelper.GenerateHashedPassword(setupDefaultParametersViewModel.Password, randomCode),
                              UserCode = TripleDES.EncryptString(randomCode)
                          };
     _userRepository.UpdateUser(userEntity);
 }
Beispiel #4
0
Datei: User.cs Projekt: LByron/BS
        public bool UpdateProfile(UserEntity userEntity)
        {
            var user = _usersTable.SingleOrDefault(u => u.UserID == userEntity.UserID);
            if (user != null)
            {
                if (string.IsNullOrEmpty(user.UserName))
                    user.UserName = userEntity.UserName;

                user.UserEmailAddress = userEntity.UserEmailAddress;
                user.UserDisplayName = userEntity.UserDisplayName;

                if (userEntity.Password != null && userEntity.UserCode != null)
                {
                    user.Password = userEntity.Password;
                    user.UserCode = userEntity.UserCode;
                }

                if (userEntity.UserActiveStatus.HasValue)
                    user.UserActiveStatus = userEntity.UserActiveStatus;

                user.ActivationKey = string.Empty;

                user.UserSite = userEntity.UserSite;

                context.SubmitChanges();
                return true;
            }
            return false;
        }
Beispiel #5
0
Datei: User.cs Projekt: LByron/BS
 public void UpdateUser(UserEntity userEntity)
 {
     var user = _usersTable.SingleOrDefault(u => u.UserID == userEntity.UserID);
     if (user != null)
     {
         user.Password = userEntity.Password;
         user.UserCode = userEntity.UserCode;
         context.SubmitChanges();
     }
 }
Beispiel #6
0
Datei: User.cs Projekt: LByron/BS
        public int RegisterUser(UserEntity userObj)
        {
            var user = new UserEntity
                           {
                               UserName = userObj.UserName,
                               UserDisplayName = userObj.UserName,
                               Password = userObj.Password,
                               UserCode = userObj.UserCode,
                               UserEmailAddress = userObj.UserEmailAddress,
                               UserActiveStatus = 1
                           };

            _usersTable.InsertOnSubmit(user);
            context.SubmitChanges();

            return user.UserID;
        }
Beispiel #7
0
 public int RegisterUser(UserEntity userObj)
 {
     throw new NotImplementedException();
 }
Beispiel #8
0
 public void UpdateUser(UserEntity userEntity)
 {
     throw new NotImplementedException();
 }
Beispiel #9
0
 public bool UpdateProfile(UserEntity userEntity)
 {
     throw new NotImplementedException();
 }
Beispiel #10
0
        /// <summary>
        /// Adds a new membership user to the data source.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.Web.Security.MembershipUser"/> object populated with the information for the newly created user.
        /// </returns>
        /// <param name="username">The user name for the new user. </param><param name="password">The password for the new user. </param><param name="email">The e-mail address for the new user.</param><param name="passwordQuestion">The password question for the new user.</param><param name="passwordAnswer">The password answer for the new user</param><param name="isApproved">Whether or not the new user is approved to be validated.</param><param name="providerUserKey">The unique identifier from the membership data source for the user.</param><param name="status">A <see cref="T:System.Web.Security.MembershipCreateStatus"/> enumeration value indicating whether the user was created successfully.</param>
        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            var args = new ValidatePasswordEventArgs(username, password, true);
            OnValidatingPassword(args);

            if (args.Cancel)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return null;
            }

            var userRepository = InstanceFactory.CreateUserInstance();
            var user = userRepository.GetUserNameByEmail(email);
            var userName = (user != null && user.UserName != string.Empty) ? user.UserName : string.Empty;

            if (RequiresUniqueEmail && userName != string.Empty)
            {
                status = MembershipCreateStatus.DuplicateEmail;
                return null;
            }

            var duplicateUser = userRepository.GetUserObjByUserName(username);

            if (user != null && duplicateUser == null && user.UserName == string.Empty)
            {
                var randomCode = RandomStringGenerator.RandomString();

                var userObj = new UserEntity
                                  {
                                      UserID = user.UserID,
                                      UserDisplayName = user.UserDisplayName,
                                      UserName = username,
                                      UserCode = TripleDES.EncryptString(randomCode),
                                      Password = PasswordHelper.GenerateHashedPassword(password, randomCode),
                                      UserEmailAddress = email,
                                      UserActiveStatus = 1
                                  };

                userRepository.UpdateProfile(userObj);

                status = MembershipCreateStatus.Success;

                return GetUser(username, true);
            }
            status = MembershipCreateStatus.DuplicateUserName;

            return null;
        }