Esempio n. 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="username"></param>
 /// <param name="currentPassword"></param>
 /// <param name="newPassword"></param>
 public void ChangePassword(string username, string currentPassword, string newPassword)
 {
     try
     {
         // verify password
         if (!DataChecker.IsValidPassword(currentPassword))
         {
             throw new SecurityException("Wrong password");
         }
         if (!DataChecker.IsValidPassword(newPassword))
         {
             throw new SecurityException("Invalid new password");
         }
         if (!DataChecker.IsValidPassword(currentPassword))
         {
             throw new SecurityException("Mật khẩu không hợp lệ.");
         }
         if (!DataChecker.IsValidPassword(newPassword))
         {
             throw new SecurityException("Mật khẩu mới không hợp lệ.");
         }
         Adapter.ChangePassword(username, currentPassword, newPassword);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="user"></param>
        public void Update(User user)
        {
            try
            {
                if (string.IsNullOrEmpty(user.FullName.Trim()))
                {
                    throw new SecurityException("Create user fail. FullName can not blank");
                }
                if (DataChecker.IsValidEmail(user.Email) == false)
                {
                    throw new SecurityException("Create user fail. Invalid email address");
                }

                Adapter.Update(user);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="fullname"></param>
        /// <param name="question"></param>
        /// <param name="answer"></param>
        /// <param name="email"></param>
        /// <returns></returns>
        public User CreateUser(string username, string password, string fullname, string email, bool blocked)
        {
            try
            {
                // validate input parameters
                if (string.IsNullOrEmpty(username.Trim()))
                {
                    throw new SecurityException("Create user fail. Username can not blank");
                }
                if (string.IsNullOrEmpty(password.Trim()))
                {
                    throw new SecurityException("Create user fail. Password can not blank");
                }
                if (string.IsNullOrEmpty(fullname.Trim()))
                {
                    throw new SecurityException("Create user fail. FullName can not blank");
                }
                if (DataChecker.IsValidEmail(email) == false)
                {
                    throw new SecurityException("Create user fail. Invalid email address");
                }
                if (DataChecker.IsValidPassword(password) == false)
                {
                    throw new SecurityException("Create user fail. Invalid password");
                }

                // create user
                User user = Adapter.Create(username, password, fullname, email, blocked);

                return(user);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }