Hi Mark,

I have had the same problem.  The main thing is to check if the user is
updating his own data, in which case you retrieve the user object from
RunData object, and to store the data in the RunData object again before
saving:


    public TibetUser updateUser(String userName, String password, String
password2, String email, ...) {
        TibetUser user;

        // retrieve the user from RunData if the user is updating his own
info, from db otherwise
        boolean userIsLoggedIn = data.getUser() != null &&
data.getUser().getName() != null;
        boolean isCurrentUser = userIsLoggedIn &&
data.getUser().getName().equals(userName);
        if (isCurrentUser) {
            user = (TibetUser) data.getUser();
        } else {
            user = getUser(userName);
        }

        // update user properties
        try {
            TurbineSecurity.changePassword(user, user.getPassword(),
password);
        } catch (...)
        }
        user.setEmail(email);

        // if the current user is updating his own user object, save the
changes to his session /before/ saving to the database
        if (userIsLoggedIn &&
data.getUser().getName().equals(user.getName())) {
            data.setUser(user);
            data.save();
        } else {
            // todo: if the updated user is logged in while someone else is
updating the profile, 
            // invalidate that user's session before saving to avoid having
it being overwritten after the user logs out
        }

        // save to database
        try {
            TurbineSecurity.saveUser(user);
        } catch (UnknownEntityException e) {
                ...
        } 
    }


Hope that helps!

/Martin
 

-----Ursprungligt meddelande-----
Från: Mark Wassermann [mailto:[EMAIL PROTECTED] 
Skickat: den 24 maj 2007 15:52
Till: Turbine Users List
Ämne: turbine user problem

hi list

I am currently trying to to write userdata to the turbine_user table (with
torque). It works fine as long as the user dose not work on its own data.
for exsample:
if my admin user is trying to write a new firstname or lastname to his
record in the db, it works as long as the user is loged in. When the user
logs out and in again, the changes are gone. I am not shure, but I think
that the TurbineSecurity calss caches the values and stores them during
logout. So I tryed to use the TurbineSecurity class to write changes to the
user table, but this class will not except the TurbineUser object as
argument in the saveUser method and a cast faild.
Is there a detailed doc to work with TurbineSecurity class or is there an
other way to do this?

thx 4 help
Mark


-- 
 Mark Wassermann            @: [EMAIL PROTECTED]
 Stolzstraße 57             @: [EMAIL PROTECTED]
 9020 Klagenfurt            w: www.mw-net.com
 Austria                    p: +43.650.6133090

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Tho' much is taken, much abides; and tho'
 We are not now that strength which in the old days  Moved earth and heaven;
that which we are, we are;  One equal-temper of heroic hearts,  Made weak by
time and fate, but strong in will  To strive, to seek, to find, and not to
yield."

 Ulysses by Alfred Tennyson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to