Exemple #1
0
        public void ChangeUsername([FromForm] string userName)
        {
            ProMaUser user = DataController.LoggedInUser;

            if (user == null)
            {
                throw new NotLoggedInException();
            }

            if (!ProMaUser.VerifyName(userName))
            {
                throw new Exception("Invalid user name");
            }

            // make sure no user with the same name
            ProMaUser existingUser = ProMaUserHandler.GetUserByUserName(userName);

            if (existingUser.IsDemo)
            {
                throw new Exception("Can't change Demo Account user name");
            }

            if (existingUser == null)
            {
                user.UserName = userName;

                ProMaUserHandler.UpdateUser(user);
            }
            else
            {
                throw new Exception("User already exists by that name");
            }
        }
Exemple #2
0
        public void ChangeEnterPref([FromForm] bool value)
        {
            ProMaUser user = DataController.LoggedInUser;

            if (user == null)
            {
                throw new NotLoggedInException();
            }

            user.EnterIsNewLinePref = value;

            ProMaUserHandler.UpdateUser(user);
        }
Exemple #3
0
        public void UpdateEmailAddress([FromForm] string emailAddress)
        {
            ProMaUser user = DataController.LoggedInUser;

            if (user == null)
            {
                throw new NotLoggedInException();
            }

            if (user.IsDemo)
            {
                throw new Exception("Can't change Demo Account email address");
            }

            user.EmailAddress = emailAddress;

            ProMaUserHandler.UpdateUser(user);
        }
Exemple #4
0
        void ClearDemoAccount()
        {
            ProMaUser demoUser = ProMaUserHandler.GetUserByUserName("DemoAccount");

            if (demoUser != null)
            {
                ProMaUserHandler.PermanentlyDeleteUser(demoUser);
            }

            ProMaUser demoAccount =
                new DataController().RegisterProMaUser(new DataController.RegisterProMaUserRequestObject()
            {
                userName = "******", md5Password = ProMaUser.ComputeMD5Hash("DemoAccount")
            });

            demoAccount.IsDemo = true;

            ProMaUserHandler.UpdateUser(demoAccount);
        }
Exemple #5
0
        public void ChangePassword([FromForm] string md5Password)
        {
            ProMaUser user = DataController.LoggedInUser;

            if (user == null)
            {
                throw new NotLoggedInException();
            }

            if (string.IsNullOrEmpty(md5Password))
            {
                throw new Exception("Invalid password");
            }

            if (user.IsDemo)
            {
                throw new Exception("Can't change Demo Account password");
            }

            user.HashedPassword = ProMaUser.ComputeSHA256(md5Password);

            ProMaUserHandler.UpdateUser(user);
        }