Extension talk:SMF Authentication

From MediaWiki.org
Jump to navigation Jump to search

I edited the login hook to work with UserLoadFromSession:

       $wgHooks['UserLoadFromSession'][]       = 'AutoAuthenticateSMF';
        * AutoAuthenticateSMF is the function that creates an automatic login if you are logged in to SMF.
        * @param User $user
        * @return bool
        * @access public
       function AutoAuthenticateSMF($user, &$result) {
               global $smf_user_info;
               //Is user a guest?
               if ($smf_user_info['is_guest'])
                       return $user;
               //User isn't a guest
               if (!$smf_user_info['is_guest']) {
                       if ($user->getID() == 0) {
                               //User doesn't exist :'(
                               $user = new User();
                               $user->setName($smf_user_info['memberName']);           // Set memberName
                               $user->setEmail($smf_user_info['email']);                       // Set Email Address.
                               $user->setRealName($smf_user_info['realName']);         // Set Real Name.
                               //if user is_admin add him to the SysOp group! Wii ;-)
                               if ($smf_user_info['is_admin'])
                       } else {
                               //User exists
                       // Go ahead and log 'em in
               $result = true;
               return $user;