Ejemplo n.º 1
0
    protected long GetUserId()
    {
        MembershipUser user = null;
        ProfileBase profile = GetProfile();
        if (profile == null)
        {
            return -1;
        }

        long userId = VolunteerTracker.Database.GetUserId();
        VolunteerTracker.Database.SetUserId(VolunteerTracker.AccessControlList.ROOT_USERID);
        user = Membership.GetUser(profile.UserName);
        VolunteerTracker.User user2 = new VolunteerTracker.User(user.Email);
        user2.Save();
        VolunteerTracker.Database.SetUserId(userId);
        return user2.Id;
    }
Ejemplo n.º 2
0
    protected void LinkButtonSaveEmailName_Click(object sender, EventArgs e)
    {
        ProfileBase profile = GetProfile();
        if (profile == null)
        {
            return;
        }
        MembershipUser user = Membership.GetUser(profile.UserName);
        VolunteerTracker.User pmUser = new VolunteerTracker.User(user.Email);
        user.Email = TextBoxEmailAddress.Text.Trim().ToLower();
        pmUser.Email = user.Email;
        pmUser.Name = TextBoxName.Text.Trim();
        pmUser.Save();
        user.IsApproved = true;
        Membership.UpdateUser(user);

        TextBoxEmailAddress.Text = user.Email;
        msg = "Saved email & name";
    }
Ejemplo n.º 3
0
    protected void ButtonAddUser_Click(object sender, EventArgs e)
    {
        string userName = TextBoxEmailAddress.Text.Trim();
        string email = TextBoxEmailAddress.Text.Trim();
        Sloppycode.PronounceablePasswordGenerator generator = new Sloppycode.PronounceablePasswordGenerator();
        ArrayList passwords = generator.Generate(1, 8);
        string defaultPassword = passwords[0].ToString();

        MembershipUserCollection members = Membership.GetAllUsers();
        foreach (MembershipUser u in members)
        {
            if (u.UserName == userName)
            {
                Session["Error"] = "<font color=\"red\">Email already in use</font>";
                return;
            }
        }

        Membership.CreateUser(userName, defaultPassword, userName);

        string role = "User";
        Roles.AddUserToRole(userName, role);
        ProfileBase.Create(userName);
        //this.profile = ProfileBase.Create(userName);
        VolunteerTracker.User user = new VolunteerTracker.User();
        user.Email = email;
        user.Name = userName;
        user.Save();
        //SaveSettings();
        string url = "quickpm.net";

        if (ConfigurationManager.AppSettings["DatabaseName"] != null)
        {
            url = ConfigurationManager.AppSettings["DatabaseName"] + ".quickpm.net";
        }
        string message = "Email: " + email + "\r\nPassword: "******"" + "\r\n" + "To login go to " + url;
        SendEmail.Send(TextBoxEmailAddress.Text.Trim(), "VolunteerTracker Login Information", message, Request.PhysicalApplicationPath);
        Session["ManageUsers-UserAdded"] = userName;
    }
Ejemplo n.º 4
0
    private void InitControls()
    {
        string userName = Request.Params["Username"];
        if (userName == null)
        {
            return;
        }
        MembershipUser user = Membership.GetUser(userName);
        if (user == null)
        {
            return;
        }
        VolunteerTracker.User pmUser = new VolunteerTracker.User(user.Email);
        pmUser.Save();
        if (TextBoxEmailAddress.Text == "")
        {

            TextBoxName.Text = pmUser.Name;
            TextBoxEmailAddress.Text = user.Email;
        }
        string[] roles = Roles.GetRolesForUser(userName);
        if (!RadioButtonUser.Checked && !RadioButtonManager.Checked)
        {
            foreach (string role in roles)
            {
                if (role == "User")
                {
                    RadioButtonUser.Checked = true;
                    RadioButtonManager.Checked = false;
                }
                else if (role == "Manager")
                {
                    RadioButtonUser.Checked = false;
                    RadioButtonManager.Checked = true;
                }
            }
        }
        long currentUserId = VolunteerTracker.Database.GetUserId();
        VolunteerTracker.Database.SetUserId(pmUser.Id);

        VolunteerTracker.Database.SetUserId(currentUserId);
        VolunteerTracker.Database.SetUserId((new VolunteerTracker.User(user.Email)).Id);
        if (!RadioButtonUser.Checked && !RadioButtonManager.Checked)
        {
            RadioButtonUser.Checked = true;
        }
        VolunteerTracker.Database.SetUserId(currentUserId);
        bool canEdit = GetCanEdit();
        RadioButtonManager.Enabled = canEdit;
        RadioButtonUser.Enabled = canEdit;
        if (!canEdit)
        {
            QuickPMWebsite.AppCode.DisableControls.DisableTextBoxControls(Page);
        }
        LinkButtonSaveEmailName.Enabled = canEdit;
        LinkButtonSaveEmailName.Visible = canEdit;
    }