is not used any more and exists only for history. Post new tickets on the Github account. n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Opened 12 years ago

Closed 12 years ago

#759 closed enhancement (duplicate)

Add a jAuth::reloadUser() method

Reported by: mike Owned by:
Priority: normal Milestone: Jelix 1.2 beta
Component: jelix:auth Version: 1.1 beta 1
Severity: minor Keywords: jauth, user
Cc: Blocked By:
Blocking: Documentation needed: no
Hosting Provider: Php version:


If we don't use the updateUser($user) method because it's easier to use the $form->saveToDao($dao) in some cases (like if you have a lot of fields). For example :

 $user->data1 = $form->getData('data1');
 $user->data2 = $form->getData('data2');
 $user->datax = $form->getData('datax');

It would be easier if we can use :


Create this method is one way to solve the problem but we can do also a method which would save the user directly from the form like that:


I think the first solution is better, what do you think of that ?

The patch for the first solution could be something like this:

    public static function reloadUser() {
        $dr = self::_getDriver();
        $config = self::_getConfig();
        $_SESSION[$config['session_name']] = jAuth::getUser($_SESSION[$config['session_name']]->login);

Change History (4)

comment:1 Changed 12 years ago by Julien

ok for me.

maybe we could call the method refreshUserInfo() ?

note :

$dr = self::_getDriver();

seems useless

maybe the method should also return the user object in session ?

comment:2 Changed 12 years ago by mike

Exactly $dr shouldn't be here... I made some changes with your comment, and by the way we it's better to use self:: so the new code below seems better :

public static function reloadUser() {
    $config = self::_getConfig();
    return $_SESSION[$config['session_name']] = self::getUser($_SESSION[$config['session_name']]->login);

comment:3 Changed 12 years ago by Julien

ok for me

will ask Laurent if this one may be landed in 1.1

comment:4 Changed 12 years ago by laurentj

  • Resolution set to duplicate
  • Status changed from new to closed

By doing this way, you don't use the auth driver. So if one day you change the driver, your code won't work. For me, this is not a good API.

And the problem here is that you reload the current user each time you update any user. This is not a good solution too.

In your case, a better way could be :

  list($user,$dao,$toInsert) = $form->prepareDaoFromControls('module~member', null, jAuth::getDriverParam('profile'));

(getDriverParam is a new method, update the trunk)

And updateUser should update the session object if this is the current user. But there is already a ticket on this issue : #461 ;-)

Note: See TracTickets for help on using tickets.