aaemnnosttv / wp-cli-login-command

Log in to WordPress with secure passwordless magic links.
https://aaemnnost.tv/wp-cli-commands/login/
MIT License
292 stars 47 forks source link

Magic login authentication fails #48

Closed knowler closed 2 years ago

knowler commented 2 years ago

I receive the following errors when using the magic login link (created with wp login create <user>):

Notice: is_embed was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /app/web/wp/wp-includes/functions.php on line 5535

Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /app/web/wp/wp-includes/functions.php on line 5535

Magic login authentication failed.

I’m installing the WP CLI package at 6ee4b91 (installed using GitHub URL instead of the package name so I can use the latest) and using dev-master for installing the plugin through Bedrock.

I’m using WordPress 5.8 with Bedrock 1.16.1 running on PHP 7.4.16, MySQL 5.7, and Nginx 1.17 via Lando 3.1.4 (Landofile below).

.lando.yml ```yml name: bedrock recipe: wordpress config: webroot: web via: nginx php: '7.4' services: appserver: run: - composer install - wp package install https://github.com/aaemnnosttv/wp-cli-login-command.git - wp core install --url=https://bedrock.lndo.site --title=Bedrock --admin_user=admin --admin_password=admin --admin_email=admin@bedrock.lndo.site --skip-email - wp plugin activate wp-cli-login-server ```
composer.json ```json { "name": "roots/bedrock", "type": "project", "license": "MIT", "description": "WordPress boilerplate with modern development tools, easier configuration, and an improved folder structure", "homepage": "https://roots.io/bedrock/", "authors": [ { "name": "Scott Walkinshaw", "email": "scott.walkinshaw@gmail.com", "homepage": "https://github.com/swalkinshaw" }, { "name": "Ben Word", "email": "ben@benword.com", "homepage": "https://github.com/retlehs" } ], "keywords": [ "bedrock", "composer", "roots", "wordpress", "wp", "wp-config" ], "support": { "issues": "https://github.com/roots/bedrock/issues", "forum": "https://discourse.roots.io/category/bedrock" }, "repositories": [ { "type": "composer", "url": "https://wpackagist.org", "only": ["wpackagist-plugin/*", "wpackagist-theme/*"] } ], "require": { "php": ">=7.1", "composer/installers": "^1.11", "vlucas/phpdotenv": "^5.3", "oscarotero/env": "^2.1", "roots/bedrock-autoloader": "^1.0", "roots/bedrock-disallow-indexing": "^2.0", "roots/wordpress": "5.8", "roots/wp-config": "1.0.0", "roots/wp-password-bcrypt": "1.0.0" }, "require-dev": { "squizlabs/php_codesniffer": "^3.6.0", "roave/security-advisories": "dev-master", "aaemnnosttv/wp-cli-login-server": "dev-master" }, "config": { "optimize-autoloader": true, "preferred-install": "dist" }, "minimum-stability": "dev", "prefer-stable": true, "extra": { "installer-paths": { "web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin"], "web/app/plugins/{$name}/": ["type:wordpress-plugin"], "web/app/themes/{$name}/": ["type:wordpress-theme"] }, "wordpress-install-dir": "web/wp" }, "scripts": { "post-root-package-install": [ "php -r \"copy('.env.example', '.env');\"" ], "test": [ "phpcs" ] } } ```
aaemnnosttv commented 2 years ago

Hey there 👋 I just gave this a try using your setup and indeed it doesn't work.

The problem is that wp package install https://github.com/aaemnnosttv/wp-cli-login-command.git will install a stale version of the package due to the https://wp-cli.org/package-index/ giving an old version (aaemnnosttv/wp-cli-login-command@ef1bcb4); see #37. This is something I've raised with wp-cli maintainers before and it hasn't really been fixed, so I'll raise it again.

The solution is to remove the wp-cli package repo set in ~/.wp-cli/packages and then run composer update. It's important to use composer directly here as wp package will re-set its repo in the config when run again.

This should get you going again

lando ssh
cd ~/.wp-cli/packages/
composer config repos.wp-cli --unset
composer update

Let me know how it goes for you 👍

knowler commented 2 years ago

Awesome, I just had to change repos.wp-cli to repositories.wp-cli in your example and it works. Thanks, @aaemnnosttv!