Exemplo n.º 1
0
        public void RemoveUser()
        {
            if (Helpers.SessionVariables.Instance.LoggedIn == false || Helpers.SessionVariables.Instance.IsAdmin == false)
            {
                return;
            }

            try
            {
                int  userid;
                bool isNumeric = int.TryParse(VpnSite.Helpers.GlobalHelper.RequestParam("id").Trim().ToLower(), out userid);
                if (!isNumeric)
                {
                    Response.Redirect("/admin/users?status=" + HttpUtility.HtmlEncode("invalid id"), false);
                }

                string removeaccount = Helpers.GlobalHelper.RequestEncodedParam("removeaccount");
                if (removeaccount != null && removeaccount == "yes")
                {
                    var user = new LibLogic.Accounts.UserInfo(userid);
                    user.RemoveAccount();


                    Response.Redirect("/admin/users?status=" + HttpUtility.HtmlEncode("User with id removed: " + userid), false);
                }
            }
            catch (Exception ex)
            {
                LibLogic.Helpers.Logging.Log(ex);
                Response.Redirect("/admin/users?status=" + HttpUtility.HtmlEncode(ex.Message), false);
            }
        }
Exemplo n.º 2
0
        public void UpdatePassword()
        {
            this.HttpContext.Response.ContentType = "text/html";
            if (Helpers.SessionVariables.Instance.LoggedIn == false)
            {
                this.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.Unauthorized;
                this.HttpContext.Response.Write("Not Logged In");
                return;
            }

            string oldpassword        = Helpers.GlobalHelper.RequestEncodedParam("oldpassword");
            string newpassword        = Helpers.GlobalHelper.RequestEncodedParam("newpassword");
            string confirmnewpassword = Helpers.GlobalHelper.RequestEncodedParam("confirmnewpassword");

            var update = new LibLogic.Accounts.UserInfo(Helpers.SessionVariables.Instance.UserId);

            try
            {
                update.UpdatePassword(oldpassword, newpassword, confirmnewpassword);
                LibLogic.ActionLog.Log_BackgroundThread("Password Changed",
                                                        Helpers.SessionVariables.Instance.UserId);
                this.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.OK;
                this.HttpContext.Response.Write("Password Updated");
            }
            catch (LibLogic.Exceptions.InvalidDataException ide)
            {
                this.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
                this.HttpContext.Response.Write(ide.Message);
            }
        }
Exemplo n.º 3
0
        public void RetreiveUserInfoTest()
        {
            Assert.That(AccountExists(emailAddress), Is.False);

            var peterAccount = new LibLogic.Accounts.CreateAccount(
                new LibLogic.Accounts.CreateAccountInfo()
            {
                Email           = emailAddress,
                EmailConfirm    = emailAddress,
                Firstname       = "Peter",
                Lastname        = "Gill",
                Password        = "******",
                PasswordConfirm = "Password1",
                BetaKey         = ""
            }
                , false, LibLogic.Setup.Email);

            var userid = peterAccount.Execute();

            Assert.That(AccountExists(emailAddress), Is.True);


            var info    = new LibLogic.Accounts.UserInfo(userid);
            var profile = info.GetProfile();

            Assert.That("Peter", Is.EqualTo(profile.FirstName));
            Assert.That("Gill", Is.EqualTo(profile.LastName));
            Assert.That(emailAddress, Is.EqualTo(profile.Email));
            Assert.That(false, Is.EqualTo(profile.Admin));
            Assert.That(false, Is.EqualTo(profile.IsBetaUser));
        }
Exemplo n.º 4
0
        public void UpdateUserInfoInvalidEmailTest()
        {
            Assert.That(AccountExists(emailAddress), Is.False);

            var peterAccount = new LibLogic.Accounts.CreateAccount(
                new LibLogic.Accounts.CreateAccountInfo()
            {
                Email           = emailAddress,
                EmailConfirm    = emailAddress,
                Firstname       = "Peter",
                Lastname        = "Gill",
                Password        = "******",
                PasswordConfirm = "Password1",
                BetaKey         = ""
            }
                , false, LibLogic.Setup.Email);

            var userid = peterAccount.Execute();

            Assert.That(AccountExists(emailAddress), Is.True);


            var info    = new LibLogic.Accounts.UserInfo(userid);
            var profile = info.GetProfile();

            info.UpdateProfile("", "Happy", "Dude");
        }
Exemplo n.º 5
0
        public Account()
        {
            var profileInfo = new LibLogic.Accounts.UserInfo(Helpers.SessionVariables.Instance.UserId).GetProfile();

            FirstName  = profileInfo.FirstName;
            LastName   = profileInfo.LastName;
            UsersEmail = profileInfo.Email;

            ChargeAmount           = LibLogic.Helpers.SiteInfo.CurrentMonthlyRate.ToString("G29");
            ChargeAmountStripCents = LibLogic.Helpers.SiteInfo.CurrentMonthlyRateInCents;
            var payInfo = new LibLogic.Payments.Payment(Helpers.SessionVariables.Instance.UserId);

            AccountExpired = payInfo.IsExpired();
            PaymentHistory = payInfo.History();
        }
Exemplo n.º 6
0
        public void UpdateProfile()
        {
            this.HttpContext.Response.ContentType = "text/html";
            if (Helpers.SessionVariables.Instance.LoggedIn == false)
            {
                this.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.Unauthorized;
                this.HttpContext.Response.Write("Not Logged In");
                return;
            }

            string email     = Helpers.GlobalHelper.RequestEncodedParam("email");
            string firstname = Helpers.GlobalHelper.RequestEncodedParam("firstname");
            string lastname  = Helpers.GlobalHelper.RequestEncodedParam("lastname");

            var update = new LibLogic.Accounts.UserInfo(Helpers.SessionVariables.Instance.UserId);

            try
            {
                update.UpdateProfile(email, firstname, lastname);

                LibLogic.ActionLog.Log_BackgroundThread(string.Format("Profile Update - Email -> {0} - First Name -> {1} - Last Name -> {2}",
                                                                      email, firstname, lastname),
                                                        Helpers.SessionVariables.Instance.UserId);

                this.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.OK;
                this.HttpContext.Response.Write("Profile Information Updated");
            }
            catch (LibLogic.Exceptions.InvalidDataException ide)
            {
                LibLogic.Helpers.Logging.Log(ide);
                this.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
                this.HttpContext.Response.Write(ide.Message);
            }
            catch (LibLogic.Exceptions.EmailAddressAlreadyUsedException eaaue)
            {
                LibLogic.Helpers.Logging.Log(eaaue);
                this.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
                this.HttpContext.Response.Write(eaaue.Message);
            }
        }