Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect 2FA code results in PHP Fatal Error #215

Open
llamaonaskateboard opened this issue Jan 19, 2025 · 1 comment
Open

Incorrect 2FA code results in PHP Fatal Error #215

llamaonaskateboard opened this issue Jan 19, 2025 · 1 comment

Comments

@llamaonaskateboard
Copy link

Not sure when this started occurring but entering an incorrect 2FA code results in the Roundcube "Oops... something went wrong!" error page with a PHP Fatal Error logged:

PHP Fatal error:  Uncaught Error: Call to a member function get() on null in /var/www/html/webmail/plugins/twofactor_gauthenticator/twofactor_gauthenticator.php:544
Stack trace:
#0 /var/www/html/webmail/plugins/twofactor_gauthenticator/twofactor_gauthenticator.php(173): twofactor_gauthenticator->__logError()
#1 /var/www/html/webmail/program/lib/Roundcube/rcube_plugin_api.php(496): twofactor_gauthenticator->check_2FAlogin()
#2 /var/www/html/webmail/program/include/rcmail_output_html.php(2131): rcube_plugin_api->exec_hook()
#3 /var/www/html/webmail/program/include/rcmail_output_html.php(711): rcmail_output_html->_write()
#4 /var/www/html/webmail/program/include/rcmail_output_html.php(846): rcmail_output_html->write()
#5 /var/www/html/webmail/program/include/rcmail_output_html.php(660): rcmail_output_html->parse()
#6 /var/www/html/webmail/program/include/rcmail.php(293): rcmail_output_html->send()
#7 /var/www/html/webmail/index.php(272): rcmail->action_handler()
#8 {main}
  thrown in /var/www/html/webmail/plugins/twofactor_gauthenticator/twofactor_gauthenticator.php on line 544

It appears the issue may be simply a missing $rcmail = rcmail::get_instance(); in __logError().

@EpeR1
Copy link

EpeR1 commented Jan 28, 2025

Try to add $rcmail = rcmail::get_instance(); to twofactor_gauthenticator.php in line 544.
#216 (comment)
Like:

// log error into $_logs_file directory
  private function __logError()
  {
    $rcmail = rcmail::get_instance();
    $_log_dir = $rcmail->config->get('log_dir');
    file_put_contents($_log_dir.'/'.$this->_logs_file, date("Y-m-d H:i:s")."|".$_SERVER['HTTP_X_FORWARDED_FOR']."|".$_SERVER['REMOTE_ADDR']."\n", FILE_APPEND);
  }

AfroThundr3007730 added a commit to AfroThundr3007730/twofactor_gauthenticator that referenced this issue Feb 19, 2025
As mentioned by @EpeR1, the missing call to `rcmail::get_instance()` caused several issues. 

Fixes: alexandregz#207, alexandregz#215  
Partial fix for alexandregz#216
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants