1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to 'reset' external authentications?

Discussion in 'XenForo Development Discussions' started by Mr. Goodie2Shoes, Nov 27, 2012.

  1. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    Is there any way to reset them instead truncating the table?
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    What do you mean by "reset"?
     
  3. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    I want to remove the external authentication data... so that the users who have already added their account needs to add them again...
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    You've kind of answered your own question really. I can't see any other way around it other than truncating the table.

    Though don't forget this will effectively lock out all of those users who have registered new accounts via the process and therefore don't have a password...

    You could write a custom script to do this in the same way the controller handles this. This would allocate passwords to those users who do not have passwords...

    PHP:
    $users = array() // Build a custom query that selects all user_id and facebook_auth_id and forms them into an array. Maybe fetchPairs would work.

    foreach ($users AS $key => $user)
    {
        
    $auth $this->_getUserModel()->getUserAuthenticationObjectByUserId($user['user_id']);
        
    $this->getModelFromCache('XenForo_Model_UserExternal')->deleteExternalAuthAssociation(
            
    'facebook'$user['facebook_auth_id'], $user['user_id']
        );

        if (!
    $auth->hasPassword())
        {
            
    $this->getModelFromCache('XenForo_Model_UserConfirmation')->resetPassword($user['user_id']);
        }    
    }
    That should loop through all users with external authentication (only considers Facebook), deletes the association and finally if they have no password set, then one is e-mailed to them.
     
    Mr. Goodie2Shoes and Jake Bunce like this.
  5. Chris D

    Chris D XenForo Developer Staff Member

    I think that code might need some work... but you get the idea.
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Mr. Goodie2Shoes likes this.
  7. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    I thought you set the password once you authenticate through facebook? :confused:
     
  8. Chris D

    Chris D XenForo Developer Staff Member

    Nope.

    If you register via the Facebook Integration feature (without first having an existing account) you do not have a password.

    You cannot login with a password, you can only login via the external provider, e.g. Facebook.

    This means if you disable Facebook Integration, you may have a load of accounts who can no longer log in to your forum.

    Likewise, if you delete your external auth table, you will have a load of accounts again who cannot log in.

    If you have an existing forum account and you associate your account with Facebook this isn't an issue because you have a password AND you have external authentication tokens. So removing those tokens won't be a problem.

    The only time a password is involved with External Auth is when you associate your existing account with Facebook, it asks you to confirm your forum password if you currently have one. This is just for verification purposes.
     
    Jake Bunce likes this.

Share This Page