Skip to content

users/remove-2fa console command is not compatible with Craft Cloud #150

@jamesmacwhite

Description

@jamesmacwhite

Description

The users/remove-2fa console command is not compatible with Craft Cloud because it requires interactivity and prompts for the authentication method as a value in an interactive prompt. The Craft Cloud console command interface does not support running any interactive commands.

The error when running the command on Craft Cloud:

./craft users/remove-2fa 93234
---
Error: craft\console\controllers\UsersController::_remove2faMethod(): Argument #1 ($method) must be of type craft\auth\methods\AuthMethodInterface, null given, called in /var/task/vendor/craftcms/cms/src/console/controllers/UsersController.php on line 572
2026-04-16 08:54:36 [console.ERROR] [TypeError] craft\console\controllers\UsersController::_remove2faMethod(): Argument #1 ($method) must be of type craft\auth\methods\AuthMethodInterface, null given, called in /var/task/vendor/craftcms/cms/src/console/controllers/UsersController.php on line 572 {"trace":["#0 /var/task/vendor/craftcms/cms/src/console/controllers/UsersController.php(572): craft\\console\\controllers\\UsersController->_remove2faMethod(NULL, Object(craft\\elements\\User))","#1 [internal function]: craft\\console\\controllers\\UsersController->remove2fa(Object(craft\\elements\\User))","#2 /var/task/vendor/craftcms/cms/src/console/CallableAction.php(43): call_user_func_array(Array, Array)","#3 /var/task/vendor/yiisoft/yii2/base/Controller.php(197): craft\\console\\CallableAction->runWithParams(Array)","#4 /var/task/vendor/yiisoft/yii2/console/Controller.php(186): yii\\base\\Controller->runAction('remove-2fa', Array)","#5 /var/task/vendor/craftcms/cms/src/console/ControllerTrait.php(88): yii\\console\\Controller->runAction('remove-2fa', Array)","#6 /var/task/vendor/craftcms/cms/src/console/Controller.php(217): craft\\console\\Controller->traitRunAction('remove-2fa', Array)","#7 /var/task/vendor/yiisoft/yii2/base/Module.php(554): craft\\console\\Controller->runAction('remove-2fa', Array)","#8 /var/task/vendor/yiisoft/yii2/console/Application.php(183): yii\\base\\Module->runAction('users/remove-2f...', Array)","#9 /var/task/vendor/craftcms/cms/src/console/Application.php(91): yii\\console\\Application->runAction('users/remove-2f...', Array)","#10 /var/task/vendor/yiisoft/yii2/console/Application.php(150): craft\\console\\Application->runAction('users/remove-2f...', Array)","#11 /var/task/vendor/craftcms/cms/src/console/Application.php(122): yii\\console\\Application->handleRequest(Object(craft\\console\\Request))","#12 /var/task/vendor/yiisoft/yii2/base/Application.php(391): craft\\console\\Application->handleRequest(Object(craft\\console\\Request))","#13 /var/task/craft(13): yii\\base\\Application->run()","#14 {main}"],"memory":65927296,"exception":"[object] (TypeError(code: 0): craft\\console\\controllers\\UsersController::_remove2faMethod(): Argument #1 ($method) must be of type craft\\auth\\methods\\AuthMethodInterface, null given, called in /var/task/vendor/craftcms/cms/src/console/controllers/UsersController.php on line 572 at /var/task/vendor/craftcms/cms/src/console/controllers/UsersController.php:609)"}
Command exited with code 1

This fails because the remove2fa method prompts for an auth method value, which cannot be provided in this context.

To support Craft Cloud, the console command should default to a value such as "all" or alternative, allow the auth method to provided as a parameter to the console controller directly, so the interactivity is not required to provide the value.

Steps to reproduce

  1. Run users/remove-2fa on a Craft Cloud environment
  2. Trigger an unhandled exception for Error: craft\console\controllers\UsersController::_remove2faMethod(): Argument #1 ($method) must be of type craft\auth\methods\AuthMethodInterface, null given, called in /var/task/vendor/craftcms/cms/src/console/controllers/UsersController.php on line 572

Additional info

  • craftcms/cms version: 5.9.20
  • craftcms/cloud version: 3.0.9
  • PHP version: 8.4
  • Database driver & version: MySQL 8.0

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions