Exemplo n.º 1
0
    protected void btnReset_Click(object sender, EventArgs e)
    {
        Users users = new Users(UserSession.LoginUser);

        users.LoadByUserID(_userID);
        if (!users.IsEmpty)
        {
            if (users[0].CryptedPassword == "")
            {
                string password = DataUtils.GenerateRandomPassword();
                users[0].CryptedPassword   = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
                users[0].IsPasswordExpired = true;
                users[0].Collection.Save();
                if (UserSession.CurrentUser.IsTSUser)
                {
                    EmailPosts.SendWelcomeTSUser(UserSession.LoginUser, users[0].UserID, password);
                }
                else
                {
                    EmailPosts.SendWelcomePortalUser(UserSession.LoginUser, users[0].UserID, password);
                }

                _manager.Alert("A new password has been sent to " + users[0].FirstName + " " + users[0].LastName);
                return;
            }
            else
            {
                if (DataUtils.ResetPassword(UserSession.LoginUser, users[0], !UserSession.CurrentUser.IsTSUser))
                {
                    _manager.Alert("A new password has been sent to " + users[0].FirstName + " " + users[0].LastName);
                    return;
                }
            }
        }
        _manager.Alert("There was an error sending the password.");
    }
Exemplo n.º 2
0
    public override bool Save()
    {
        User  user;
        Users users = new Users(UserSession.LoginUser);

        Organization organization = Organizations.GetOrganization(UserSession.LoginUser, UserSession.LoginUser.OrganizationID);

        string email = textEmail.Text.Trim();

        if (email.Length < 1 || email.IndexOf('@') < 0 || email.IndexOf('.') < 0 || !users.IsEmailValid(email, _userID, _organizationID))
        {
            _manager.Alert("The email you have specified is invalid.  Please choose another email.");
            return(false);
        }

        if (textFirstName.Text.Trim().Length < 1 || textLastName.Text.Trim().Length < 1)
        {
            _manager.Alert("The name you have specified is invalid.  Please enter your name.");
            return(false);
        }


        if (cbChat.Checked && Organizations.GetChatCount(UserSession.LoginUser, UserSession.LoginUser.OrganizationID) >= organization.ChatSeats)
        {
            _manager.Alert("You have exceeded your chat licenses.  Please purchase more seats to add additional chat users.");
            cbChat.Checked = false;
            return(false);
        }

        if (_userID < 0)
        {
            if (Organizations.GetUserCount(UserSession.LoginUser, UserSession.LoginUser.OrganizationID) >= organization.UserSeats)
            {
                _manager.Alert("You have exceeded your user licenses.  Please send an email to [email protected] if you would like to add additional users your account.");
                return(false);
            }

            user = users.AddNewUser();
            user.OrganizationID = _organizationID;
            if (cbActive.Checked)
            {
                user.ActivatedOn = DateTime.UtcNow;
            }
            user.LastLogin                  = DateTime.UtcNow;
            user.LastActivity               = DateTime.UtcNow;
            user.IsPasswordExpired          = true;
            user.ReceiveTicketNotifications = true;
            user.EnforceSingleSession       = true;
            user.IsClassicView              = true;
        }
        else
        {
            users.LoadByUserID(_userID);
            if (users.IsEmpty)
            {
                _manager.Alert("There was an error updating the user information");
                return(false);
            }

            user = users[0];
            if (user.IsActive && !cbActive.Checked)
            {
                user.DeactivatedOn = DateTime.UtcNow;
                Organizations orgs = new Organizations(TSAuthentication.GetLoginUser());
                orgs.ResetDefaultSupportUser(TSAuthentication.GetLoginUser(), user.UserID);
            }

            if (true)
            {
                if (!user.IsActive && cbActive.Checked && Organizations.GetUserCount(UserSession.LoginUser, UserSession.LoginUser.OrganizationID) >= organization.UserSeats)
                {
                    _manager.Alert("You have exceeded your user licenses.  Please send an email to [email protected] if you would like to add additional users your account.");
                    return(false);
                }
            }
        }

        user.Email        = textEmail.Text.Trim();
        user.FirstName    = textFirstName.Text.Trim();
        user.LastName     = textLastName.Text.Trim();
        user.MiddleName   = textMiddleName.Text.Trim();
        user.Title        = textTitle.Text;
        user.IsPortalUser = true;
        user.TimeZoneID   = cmbTimeZones.SelectedValue;
        user.CultureName  = cmbDateFormat.SelectedValue;
        user.FontFamily   = (FontFamily)Convert.ToInt32(cmbFontFamilies.SelectedValue);
        user.FontSize     = (TeamSupport.Data.FontSize)Convert.ToInt32(cmbFontSizes.SelectedValue);
        user.ReceiveTicketNotifications        = cbEmailNotify.Checked;
        user.SubscribeToNewTickets             = cbSubscribe.Checked;
        user.SubscribeToNewActions             = cbSubscribeAction.Checked;
        user.ReceiveAllGroupNotifications      = cbReceiveGroup.Checked;
        user.DoNotAutoSubscribe                = cbNoAutoSubscribe.Checked;
        user.RestrictUserFromEditingAnyActions = cbRestrictUserFromEditingAnyActions.Checked;
        user.AllowUserToEditAnyAction          = cbAllowUserToEditAnyAction.Checked;
        user.UserCanPinAction = cbUserCanPinAction.Checked;
        user.TicketRights     = (TicketRightType)int.Parse(cmbRights.SelectedValue);
        user.ShowWelcomePage  = true;
        UserSession.LoginUser.TimeZoneInfo = null;

        if (UserSession.CurrentUser.IsSystemAdmin)
        {
            user.IsActive      = cbActive.Checked;
            user.IsSystemAdmin = cbIsSystemAdmin.Checked;
            user.IsChatUser    = cbChat.Checked;
        }


        string checkRequired = _fieldControls.CheckRequiredCustomFields();

        if (checkRequired != "")
        {
            _manager.Alert(checkRequired);
            return(false);
        }

        user.Collection.Save();

        if (user.IsActive)
        {
            user.EmailCountToMuroc(true);
        }

        _fieldControls.RefID = user.UserID;
        _fieldControls.SaveCustomFields();

        if (_userID < 0)
        {
            string password = DataUtils.GenerateRandomPassword();
            user.CryptedPassword    = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
            user.IsPasswordExpired  = true;
            user.PasswordCreatedUtc = DateTime.UtcNow;
            user.Collection.Save();
            if (cbEmail.Checked)
            {
                EmailPosts.SendWelcomeTSUser(UserSession.LoginUser, user.UserID, password);
            }

            Organization orgTemplate = Organizations.GetTemplateOrganization(UserSession.LoginUser, organization.ProductType);

            if (orgTemplate != null)
            {
                UserSettings.WriteString(UserSession.LoginUser, user.UserID, "Dashboard", UserSettings.ReadString(UserSession.LoginUser, (int)orgTemplate.PrimaryUserID, "Dashboard"));
            }
        }

        TeamSupportSync.SyncUser(user.UserID, user.OrganizationID, user.FirstName, user.LastName, user.Email, user.Title);

        if (UserSession.CurrentUser.UserID == _userID)
        {
            UserSession.RefreshCurrentUserInfo();
            UserSession.RefreshLoginUser();
        }


        return(true);
    }
Exemplo n.º 3
0
    public override bool Save()
    {
        User  user;
        Users users    = new Users(UserSession.LoginUser);;
        int   newOrgID = int.Parse(cmbCustomer.SelectedValue);


        string email = textEmail.Text.Trim();

        if ((cbIsPortalUser.Checked) && (email.Length < 1 || email.IndexOf('@') < 0 || email.IndexOf('.') < 0))
        {
            _manager.Alert("The email you have specified is invalid.  Please choose another email.");
            return(false);
        }

        if (email != "" && !users.IsEmailValid(email, _userID, newOrgID))
        {
            _manager.Alert("The email you have specified is already in use.  Please choose another email.");
            return(false);
        }

        if (textFirstName.Text.Trim().Length < 1 || textLastName.Text.Trim().Length < 1)
        {
            _manager.Alert("The name you have specified is invalid.  Please enter your name.");
            return(false);
        }


        if (_userID < 0)
        {
            user = users.AddNewUser();
            user.OrganizationID = newOrgID;
            if (cbActive.Checked)
            {
                user.ActivatedOn = DateTime.UtcNow;
            }
            user.LastLogin                  = DateTime.UtcNow;
            user.LastActivity               = DateTime.UtcNow.AddHours(-1);
            user.IsPasswordExpired          = true;
            user.ReceiveTicketNotifications = true;
        }
        else
        {
            users.LoadByUserID(_userID);
            if (users.IsEmpty)
            {
                _manager.Alert("There was an error updating the user information");
                return(false);
            }

            user = users[0];
            if (user.IsActive && !cbActive.Checked)
            {
                user.DeactivatedOn = DateTime.UtcNow;
            }
            if (user.OrganizationID != newOrgID)
            {
                user.OrganizationID = newOrgID;
                Tickets tickets = new Tickets(UserSession.LoginUser);
                tickets.LoadByContact(user.UserID);
                foreach (Ticket ticket in tickets)
                {
                    tickets.AddOrganization(newOrgID, ticket.TicketID);
                }
            }
        }

        user.Email             = textEmail.Text;
        user.FirstName         = textFirstName.Text;
        user.LastName          = textLastName.Text;
        user.Title             = textTitle.Text;
        user.MiddleName        = textMiddleName.Text;
        user.BlockInboundEmail = cbBlockEmail.Checked;


        user.IsActive = cbActive.Checked;

        if (UserSession.CurrentUser.HasPortalRights && UserSession.CurrentUser.IsSystemAdmin)
        {
            user.IsPortalUser = cbIsPortalUser.Checked;
        }

        if (UserSession.CurrentUser.IsTSUser && UserSession.CurrentUser.IsSystemAdmin)
        {
            user.IsSystemAdmin  = cbIsSystemAdmin.Checked;
            user.IsFinanceAdmin = cbIsFinanceAdmin.Checked;
        }



        user.Collection.Save();

        _fieldControls.RefID = user.UserID;
        _fieldControls.SaveCustomFields();

        if (_userID < 0)
        {
            string password = DataUtils.GenerateRandomPassword();
            user.CryptedPassword   = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
            user.IsPasswordExpired = true;
            user.Collection.Save();
            if (UserSession.CurrentUser.IsTSUser && cbEmail.Checked)
            {
                EmailPosts.SendWelcomeTSUser(UserSession.LoginUser, user.UserID, password);
            }
            else if (cbEmail.Checked && cbIsPortalUser.Checked)
            {
                EmailPosts.SendWelcomePortalUser(UserSession.LoginUser, user.UserID, password);
            }
        }

        return(true);
    }