0

I'm working on a acquia site and right now the dev environment is replicated from the prod. I want to be able to get in as admin on the dev site, but every time i hit the /user path it redirects me back to the prod site. I tried doing a drush uli admin but that doesnt work neither as I still get redirected back to prod. However, I am logged in as admin on the prod by doing a drush uli admin.

Without touching any of the code/files to get me logged into the dev site and only using Drush. How can one get in logged as admin?

Keep in mind there's no way to get to the /user path on dev as it redirects you once you land on there. And I'm not sure which modules/files is doing this functionality.

I was thinking of copying the cookie session from the prod database and then copy it into the dev database to simulate myself as being logged in, but I'm not sure how to go about that or what else might be needed.

  • 1
    Sounds like you have a custom redirect, that'll probably either be in code or the database. If it's in the database you can run a query (or set a variable) via drush, if it's in code you're out of luck – Clive Aug 28 '15 at 17:17
  • Is the $base_url hardcoded in settings.php? – mpdonadio Aug 28 '15 at 17:22
  • how do you view the $base_url in settings.php when it resides on the acquia servers? – Patoshi パトシ Aug 28 '15 at 17:34
  • 1
    You have a local settings.php too @duckx – Clive Aug 28 '15 at 17:43
0

Use drush to get a list of enabled modules except for core:

drush pm-list --type=Module --no-core

If the module Rename Admin Paths is being used then you can use drush to temporarily disable it until you are logged in.

ie.

drush pm-disable rename_admin_paths

or

drush dis rename_admin_paths  

I'm suggesting this as that particular module in known to be one of the causes of redirects involving administrators and the /user path.

0

What I did was change the default theme to the basic seven theme:

drush @mydomain.dev vset theme_default seven

Then reset your admin password:

drush @mydomain.dev upwd admin --password="mypass"

Then go and find a page that loads the seven theme and by default the seven theme has the login block somewhere in the footer area. Login with admin and your new pass! =D

If you have a theme switching module, you'll have to turn that off too. Such as themekey or rules or securepages (this is what was causing my issue.)

0

Try the following workarounds:

  • /user/login instead of just /user
  • try: drush uli and try both http:// and https://, maybe it could make a difference, or adding ?foo at the end of the URI
  • give every session an admin: drush sqlq "UPDATE sessions SET uid = 1" (make sure your browser session is included already there)
  • hack index.php by adding the following line just after drupal_bootstrap()

    global $user; $user = user_load(1); session_start(); user_login_finalize();
    

    See also: How do I programmatically log in a user?

  • create a dummy session and hijack the cookie in the browser:

    $ drush eval 'global $user; session_start(); user_login_finalize(); echo session_name();'
    $ drush sqlq "UPDATE sessions SET uid = 1 ORDER BY timestamp DESC LIMIT 1"
    

    then in the browser address bar type (to set the cookie):

    javascript:document.cookie="SESS37XXX=NGnGrXXX"
    

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.