5

I somehow managed to lock myself out of a Drupal 9 installation after setting up TFA with Google Authenticator login. So, i know my user1 name, my user 1 password, but TFA doesn't allow me backend access, because the app is misconfigured. I still have FTP, DB and SSH access.

I already did this two years ago on another site. That time I added a line to settings.php that granted admin role to anonymous user. But I cannot find this solution anymore.

Any help would make my day!

3
  • Can you get in with drush uli? – Danny Englander Jan 20 at 13:39
  • sorrily not, because drush is not installed. – Berry Dingle Jan 20 at 13:40
  • 3
    You'll need Drush. My advise is to set it up locally, get Drush, and uninstall Google TFA. Commit that and deploy, then try again (but proof TFA locally first). – Kevin Jan 20 at 13:49
6

I post this as an answer, because someone might be as stupid as I am :) I browsed various old backups and found the settings.php line that grants admin permissions to anonymous user, and it worked.

If you add:

$config['user.role.anonymous']['is_admin'] = 'true';

in your settings.php, every anonymous user is admin. That way I could get back into admin panel and uninstall TFA and Google Authenticator. Deleted the line, logged back in as user1 and installed both modules again.

Handy way to do it, if you don't have drush. But not recommended for production sites obviously.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.