예제 #1
0
        /// <summary>
        /// Authenticates a user and if successful returns a user instance
        /// </summary>
        /// <param name="strUserName"></param>
        /// <param name="strPassword"></param>
        /// <returns></returns>
        public UserBO ValidateUserAndLoad(string strUserName, string strPassword)
        {
            if (string.IsNullOrEmpty(strUserName) || string.IsNullOrEmpty(strPassword))
            {
                return(null);
            }

            SecurityBAL objSecurityBAL = new SecurityBAL();

            string       strResult       = "";
            UserMasterBO objUserMasterBO = objSecurityBAL.verifyLogin(strUserName, strPassword, ref strResult);
            UserBO       objUserBO       = null;

            if (strResult == "SUCCESS")
            {
                objUserBO            = new UserBO();
                objUserBO.UserId     = objUserMasterBO.UserId;
                objUserBO.FirstName  = objUserMasterBO.FirstName;
                objUserBO.LastName   = objUserMasterBO.LastName;
                objUserBO.UserName   = objUserMasterBO.UserName;
                objUserBO.EmailId    = objUserMasterBO.EmailId;
                objUserBO.Gender     = objUserMasterBO.Gender;
                objUserBO.Address    = objUserMasterBO.Address;
                objUserBO.PhoneNo    = objUserMasterBO.PhoneNo;
                objUserBO.IsActive   = objUserMasterBO.IsActive;
                objUserBO.RoleId     = objUserMasterBO.RoleId;
                objUserBO.RoleName   = objUserMasterBO.RoleName;
                objUserBO.EmployeeId = objUserMasterBO.EmployeeId;
            }

            //string encodedPassword = AppSecurity.EncodePassword(strUserName, objUserBO.UserId);

            if (strResult == "IN_VALID")
            {
                SetError("Invalid username or password.");
                return(null);
            }

            if (strResult == "IN_ACTIVE")
            {
                SetError("User is not active. Please contact administrator");
                return(null);
            }

            return(objUserBO);
        }
예제 #2
0
        /// <summary>
        /// Validates a user by username
        /// </summary>
        /// <param name="Username"></param>
        /// <param name="Password"></param>
        /// <returns></returns>
        public bool ValidateUser(string strUsername, string strPassword)
        {
            SetError();
            if (string.IsNullOrEmpty(strUsername) || string.IsNullOrEmpty(strPassword))
            {
                SetError("Empty usernames or passwords are not allowed");
                return(false);
            }
            SecurityBAL objSecurityBAL = new SecurityBAL();

            string       strResult       = "";
            UserMasterBO objUserMasterBO = objSecurityBAL.verifyLogin(strUsername, strPassword, ref strResult);
            UserBO       objUserBO       = null;

            if (strResult == "SUCCESS")
            {
                objUserBO  = new UserBO();
                UserId     = objUserMasterBO.UserId;
                FirstName  = objUserMasterBO.FirstName;
                LastName   = objUserMasterBO.LastName;
                UserName   = objUserMasterBO.UserName;
                EmailId    = objUserMasterBO.EmailId;
                Gender     = objUserMasterBO.Gender;
                Address    = objUserMasterBO.Address;
                PhoneNo    = objUserMasterBO.PhoneNo;
                IsActive   = objUserMasterBO.IsActive;
                EmployeeId = objUserMasterBO.EmployeeId;
            }

            if (strResult == "IN_VALID")
            {
                SetError("Invalid username or password.");
                return(false);
            }

            if (strResult == "IN_ACTIVE")
            {
                SetError("User is not active. Please contact administrator");
                return(false);
            }


            return(true);
        }