[GH-ISSUE #670] Touble enabling 2FA for login #438

Closed
opened 2026-02-25 21:35:01 +03:00 by kerem · 4 comments
Owner

Originally created by @knightsg on GitHub (Feb 14, 2023).
Original GitHub issue: https://github.com/cypht-org/cypht/issues/670

💬 Question

I've set up the 2fa module by uncommenting the module line in hm3.ini, setting a secret in the 2fa.ini file and moving it to the app_data dir. If I log into Cypht and go to site settings I see the option for 2FA, I can scan the QR code and enable 2FA using the checkbox, then save the setting. However, when I try to log out of Cypht so I can log back in to try it, I get a popup box saying I need to enter my passed to save settings.

I've done this and logged out, but when I log back in I don't get any 2FA prompt and if I go back to the 2FA settings again the checkbox is not selected. I've tried the same process a few extra times with no change. If I follow the process to enable 2FA and then browse around the site without trying to log out, I don't get the popup, and if I go back to 2FA settings the checkbox is still selected. I've also tried instead selecting "Just logout" when the popup shows, but I get the same result.

In case it helps here are the cypht log lines when I save the 2FA setting:

mailserver-cypht-1 | NOTICE: PHP message: Array
mailserver-cypht-1 | (
mailserver-cypht-1 | [0] => Using Hm_PHP_Session with Hm_Auth_IMAP
mailserver-cypht-1 | [1] => Using file based user configuration
mailserver-cypht-1 | [2] => Using sapi: fpm-fcgi
mailserver-cypht-1 | [3] => Request type: HTTP
mailserver-cypht-1 | [4] => Request path: /
mailserver-cypht-1 | [5] => TLS request: 0
mailserver-cypht-1 | [6] => Mobile request: 0
mailserver-cypht-1 | [7] => Page ID: settings
mailserver-cypht-1 | [8] => CACHE backend using: noop
mailserver-cypht-1 | [9] => LOGGED IN
mailserver-cypht-1 | [10] => Setting cookie: name: hm_reload_folders, lifetime: 0, path: , domain: localhost, secure: , html_only
mailserver-cypht-1 | [11] => Setting cookie: name: hm_msgs, lifetime: 0, path: /, domain: localhost, secure: , html_only 1
mailserver-cypht-1 | [12] => Redirecting to /?page=settings
mailserver-cypht-1 | [13] => PHP version 8.2.2
mailserver-cypht-1 | [14] => Zend version 4.2.2
mailserver-cypht-1 | [15] => Peak Memory: 8192
mailserver-cypht-1 | [16] => PID: 13
mailserver-cypht-1 | [17] => Included files: 112
mailserver-cypht-1 | )
mailserver-cypht-1 | 172.30.0.4 - 14/Feb/2023:07:36:29 +0000 "POST /index.php" 303
mailserver-cypht-1 | NOTICE: PHP message: Array
mailserver-cypht-1 | (
mailserver-cypht-1 | [0] => Using Hm_PHP_Session with Hm_Auth_IMAP
mailserver-cypht-1 | [1] => Using file based user configuration
mailserver-cypht-1 | [2] => Using sapi: fpm-fcgi
mailserver-cypht-1 | [3] => Request type: HTTP
mailserver-cypht-1 | [4] => Request path: /
mailserver-cypht-1 | [5] => TLS request: 0
mailserver-cypht-1 | [6] => Mobile request: 0
mailserver-cypht-1 | [7] => Page ID: settings
mailserver-cypht-1 | [8] => CACHE backend using: noop
mailserver-cypht-1 | [9] => LOGGED IN
mailserver-cypht-1 | [10] => Deleting cookie: name: hm_msgs, lifetime: 1676356589, path: /, domain: localhost, secure: , html_only 1
mailserver-cypht-1 | [11] => TRANSLATION NOT FOUND :Attachment Chunks:
mailserver-cypht-1 | [12] => TRANSLATION NOT FOUND :Farsi:
mailserver-cypht-1 | [13] => TRANSLATION NOT FOUND :Estonian:
mailserver-cypht-1 | [14] => TRANSLATION NOT FOUND :Indonesian:
mailserver-cypht-1 | [15] => TRANSLATION NOT FOUND :Too Dark:
mailserver-cypht-1 | [16] => TRANSLATION NOT FOUND :Don't flag a message as read on open:
mailserver-cypht-1 | [17] => TRANSLATION NOT FOUND :Default message sort order:
mailserver-cypht-1 | [18] => TRANSLATION NOT FOUND :Update your settings with the code below:
mailserver-cypht-1 | [19] => TRANSLATION NOT FOUND :If you can't use the QR code, you can enter the code below manually (no line breaks):
mailserver-cypht-1 | [20] => PHP version 8.2.2
mailserver-cypht-1 | [21] => Zend version 4.2.2
mailserver-cypht-1 | [22] => Peak Memory: 10240
mailserver-cypht-1 | [23] => PID: 12
mailserver-cypht-1 | [24] => Included files: 113
mailserver-cypht-1 | )
mailserver-cypht-1 | 172.30.0.4 - 14/Feb/2023:07:36:29 +0000 "GET /index.php" 200
mailserver-cypht-1 | 172.30.0.4 - 14/Feb/2023:07:36:29 +0000 "POST /index.php" 200
mailserver-cypht-1 | NOTICE: PHP message: Array
mailserver-cypht-1 | (
mailserver-cypht-1 | [0] => Using Hm_PHP_Session with Hm_Auth_IMAP
mailserver-cypht-1 | [1] => Using file based user configuration
mailserver-cypht-1 | [2] => Using sapi: fpm-fcgi
mailserver-cypht-1 | [3] => Request type: AJAX
mailserver-cypht-1 | [4] => Request path: /
mailserver-cypht-1 | [5] => TLS request: 0
mailserver-cypht-1 | [6] => Mobile request: 0
mailserver-cypht-1 | [7] => Page ID: ajax_hm_folders
mailserver-cypht-1 | [8] => CACHE backend using: noop
mailserver-cypht-1 | [9] => LOGGED IN
mailserver-cypht-1 | [10] => Deleting cookie: name: hm_reload_folders, lifetime: 1676356589, path: , domain: localhost, secure: , html_only
mailserver-cypht-1 | [11] => TRANSLATION NOT FOUND :Highlights:
mailserver-cypht-1 | [12] => TRANSLATION NOT FOUND :Hide folders:
mailserver-cypht-1 | [13] => PHP version 8.2.2
mailserver-cypht-1 | [14] => Zend version 4.2.2
mailserver-cypht-1 | [15] => Peak Memory: 8192
mailserver-cypht-1 | [16] => PID: 13
mailserver-cypht-1 | [17] => Included files: 71
mailserver-cypht-1 | )

This block is when I've configured 2FA and try to log out using the "save and logout" option that pops up:

mailserver-cypht-1 | NOTICE: PHP message: Array
mailserver-cypht-1 | 172.30.0.4 - 14/Feb/2023:07:37:44 +0000 "POST /index.php" 303
mailserver-cypht-1 | (
mailserver-cypht-1 | [0] => Using Hm_PHP_Session with Hm_Auth_IMAP
mailserver-cypht-1 | [1] => Using file based user configuration
mailserver-cypht-1 | [2] => Using sapi: fpm-fcgi
mailserver-cypht-1 | [3] => Request type: HTTP
mailserver-cypht-1 | [4] => Request path: /
mailserver-cypht-1 | [5] => TLS request: 0
mailserver-cypht-1 | [6] => Mobile request: 0
mailserver-cypht-1 | [7] => Page ID: settings
mailserver-cypht-1 | [8] => CACHE backend using: noop
mailserver-cypht-1 | [9] => LOGGED IN
mailserver-cypht-1 | [10] => Deleting cookie: name: hm_session, lifetime: 1676356664, path: /, domain: localhost, secure: , html_only 1
mailserver-cypht-1 | [11] => Deleting cookie: name: hm_id, lifetime: 1676356664, path: /, domain: localhost, secure: , html_only 1
mailserver-cypht-1 | [12] => Deleting cookie: name: hm_reload_folders, lifetime: 1676356664, path: , domain: localhost, secure: , html_only
mailserver-cypht-1 | [13] => Deleting cookie: name: hm_msgs, lifetime: 1676356664, path: /, domain: localhost, secure: , html_only 1
mailserver-cypht-1 | [14] => Setting cookie: name: hm_msgs, lifetime: 0, path: /, domain: localhost, secure: , html_only 1
mailserver-cypht-1 | [15] => Redirecting to /?page=settings
mailserver-cypht-1 | [16] => PHP version 8.2.2
mailserver-cypht-1 | [17] => Zend version 4.2.2
mailserver-cypht-1 | [18] => Peak Memory: 8192
mailserver-cypht-1 | [19] => PID: 12
mailserver-cypht-1 | [20] => Included files: 112
mailserver-cypht-1 | )
mailserver-cypht-1 | NOTICE: PHP message: Array
mailserver-cypht-1 | 172.30.0.4 - 14/Feb/2023:07:37:44 +0000 "GET /index.php" 200
mailserver-cypht-1 | (
mailserver-cypht-1 | [0] => Using Hm_PHP_Session with Hm_Auth_IMAP
mailserver-cypht-1 | [1] => Using file based user configuration
mailserver-cypht-1 | [2] => Using sapi: fpm-fcgi
mailserver-cypht-1 | [3] => Request type: HTTP
mailserver-cypht-1 | [4] => Request path: /
mailserver-cypht-1 | [5] => TLS request: 0
mailserver-cypht-1 | [6] => Mobile request: 0
mailserver-cypht-1 | [7] => Page ID: settings
mailserver-cypht-1 | [8] => CACHE backend using: noop
mailserver-cypht-1 | [9] => Deleting cookie: name: hm_msgs, lifetime: 1676356664, path: /, domain: localhost, secure: , html_only 1
mailserver-cypht-1 | [10] => TRANSLATION NOT FOUND :Cypht:
mailserver-cypht-1 | [11] => PHP version 8.2.2
mailserver-cypht-1 | [12] => Zend version 4.2.2
mailserver-cypht-1 | [13] => Peak Memory: 8192
mailserver-cypht-1 | [14] => PID: 13
mailserver-cypht-1 | [15] => Included files: 68
mailserver-cypht-1 | )

FYI I am using IMAP auth provided by a container running docker-mailserver.

Originally created by @knightsg on GitHub (Feb 14, 2023). Original GitHub issue: https://github.com/cypht-org/cypht/issues/670 ## 💬 Question I've set up the 2fa module by uncommenting the module line in hm3.ini, setting a secret in the 2fa.ini file and moving it to the app_data dir. If I log into Cypht and go to site settings I see the option for 2FA, I can scan the QR code and enable 2FA using the checkbox, then save the setting. However, when I try to log out of Cypht so I can log back in to try it, I get a popup box saying I need to enter my passed to save settings. I've done this and logged out, but when I log back in I don't get any 2FA prompt and if I go back to the 2FA settings again the checkbox is not selected. I've tried the same process a few extra times with no change. If I follow the process to enable 2FA and then browse around the site without trying to log out, I don't get the popup, and if I go back to 2FA settings the checkbox is still selected. I've also tried instead selecting "Just logout" when the popup shows, but I get the same result. In case it helps here are the cypht log lines when I save the 2FA setting: _mailserver-cypht-1 | NOTICE: PHP message: Array mailserver-cypht-1 | ( mailserver-cypht-1 | [0] => Using Hm_PHP_Session with Hm_Auth_IMAP mailserver-cypht-1 | [1] => Using file based user configuration mailserver-cypht-1 | [2] => Using sapi: fpm-fcgi mailserver-cypht-1 | [3] => Request type: HTTP mailserver-cypht-1 | [4] => Request path: / mailserver-cypht-1 | [5] => TLS request: 0 mailserver-cypht-1 | [6] => Mobile request: 0 mailserver-cypht-1 | [7] => Page ID: settings mailserver-cypht-1 | [8] => CACHE backend using: noop mailserver-cypht-1 | [9] => LOGGED IN mailserver-cypht-1 | [10] => Setting cookie: name: hm_reload_folders, lifetime: 0, path: , domain: localhost, secure: , html_only mailserver-cypht-1 | [11] => Setting cookie: name: hm_msgs, lifetime: 0, path: /, domain: localhost, secure: , html_only 1 mailserver-cypht-1 | [12] => Redirecting to /?page=settings mailserver-cypht-1 | [13] => PHP version 8.2.2 mailserver-cypht-1 | [14] => Zend version 4.2.2 mailserver-cypht-1 | [15] => Peak Memory: 8192 mailserver-cypht-1 | [16] => PID: 13 mailserver-cypht-1 | [17] => Included files: 112 mailserver-cypht-1 | ) mailserver-cypht-1 | 172.30.0.4 - 14/Feb/2023:07:36:29 +0000 "POST /index.php" 303 mailserver-cypht-1 | NOTICE: PHP message: Array mailserver-cypht-1 | ( mailserver-cypht-1 | [0] => Using Hm_PHP_Session with Hm_Auth_IMAP mailserver-cypht-1 | [1] => Using file based user configuration mailserver-cypht-1 | [2] => Using sapi: fpm-fcgi mailserver-cypht-1 | [3] => Request type: HTTP mailserver-cypht-1 | [4] => Request path: / mailserver-cypht-1 | [5] => TLS request: 0 mailserver-cypht-1 | [6] => Mobile request: 0 mailserver-cypht-1 | [7] => Page ID: settings mailserver-cypht-1 | [8] => CACHE backend using: noop mailserver-cypht-1 | [9] => LOGGED IN mailserver-cypht-1 | [10] => Deleting cookie: name: hm_msgs, lifetime: 1676356589, path: /, domain: localhost, secure: , html_only 1 mailserver-cypht-1 | [11] => TRANSLATION NOT FOUND :Attachment Chunks: mailserver-cypht-1 | [12] => TRANSLATION NOT FOUND :Farsi: mailserver-cypht-1 | [13] => TRANSLATION NOT FOUND :Estonian: mailserver-cypht-1 | [14] => TRANSLATION NOT FOUND :Indonesian: mailserver-cypht-1 | [15] => TRANSLATION NOT FOUND :Too Dark: mailserver-cypht-1 | [16] => TRANSLATION NOT FOUND :Don't flag a message as read on open: mailserver-cypht-1 | [17] => TRANSLATION NOT FOUND :Default message sort order: mailserver-cypht-1 | [18] => TRANSLATION NOT FOUND :Update your settings with the code below: mailserver-cypht-1 | [19] => TRANSLATION NOT FOUND :If you can't use the QR code, you can enter the code below manually (no line breaks): mailserver-cypht-1 | [20] => PHP version 8.2.2 mailserver-cypht-1 | [21] => Zend version 4.2.2 mailserver-cypht-1 | [22] => Peak Memory: 10240 mailserver-cypht-1 | [23] => PID: 12 mailserver-cypht-1 | [24] => Included files: 113 mailserver-cypht-1 | ) mailserver-cypht-1 | 172.30.0.4 - 14/Feb/2023:07:36:29 +0000 "GET /index.php" 200 mailserver-cypht-1 | 172.30.0.4 - 14/Feb/2023:07:36:29 +0000 "POST /index.php" 200 mailserver-cypht-1 | NOTICE: PHP message: Array mailserver-cypht-1 | ( mailserver-cypht-1 | [0] => Using Hm_PHP_Session with Hm_Auth_IMAP mailserver-cypht-1 | [1] => Using file based user configuration mailserver-cypht-1 | [2] => Using sapi: fpm-fcgi mailserver-cypht-1 | [3] => Request type: AJAX mailserver-cypht-1 | [4] => Request path: / mailserver-cypht-1 | [5] => TLS request: 0 mailserver-cypht-1 | [6] => Mobile request: 0 mailserver-cypht-1 | [7] => Page ID: ajax_hm_folders mailserver-cypht-1 | [8] => CACHE backend using: noop mailserver-cypht-1 | [9] => LOGGED IN mailserver-cypht-1 | [10] => Deleting cookie: name: hm_reload_folders, lifetime: 1676356589, path: , domain: localhost, secure: , html_only mailserver-cypht-1 | [11] => TRANSLATION NOT FOUND :Highlights: mailserver-cypht-1 | [12] => TRANSLATION NOT FOUND :Hide folders: mailserver-cypht-1 | [13] => PHP version 8.2.2 mailserver-cypht-1 | [14] => Zend version 4.2.2 mailserver-cypht-1 | [15] => Peak Memory: 8192 mailserver-cypht-1 | [16] => PID: 13 mailserver-cypht-1 | [17] => Included files: 71 mailserver-cypht-1 | )_ This block is when I've configured 2FA and try to log out using the "save and logout" option that pops up: _mailserver-cypht-1 | NOTICE: PHP message: Array mailserver-cypht-1 | 172.30.0.4 - 14/Feb/2023:07:37:44 +0000 "POST /index.php" 303 mailserver-cypht-1 | ( mailserver-cypht-1 | [0] => Using Hm_PHP_Session with Hm_Auth_IMAP mailserver-cypht-1 | [1] => Using file based user configuration mailserver-cypht-1 | [2] => Using sapi: fpm-fcgi mailserver-cypht-1 | [3] => Request type: HTTP mailserver-cypht-1 | [4] => Request path: / mailserver-cypht-1 | [5] => TLS request: 0 mailserver-cypht-1 | [6] => Mobile request: 0 mailserver-cypht-1 | [7] => Page ID: settings mailserver-cypht-1 | [8] => CACHE backend using: noop mailserver-cypht-1 | [9] => LOGGED IN mailserver-cypht-1 | [10] => Deleting cookie: name: hm_session, lifetime: 1676356664, path: /, domain: localhost, secure: , html_only 1 mailserver-cypht-1 | [11] => Deleting cookie: name: hm_id, lifetime: 1676356664, path: /, domain: localhost, secure: , html_only 1 mailserver-cypht-1 | [12] => Deleting cookie: name: hm_reload_folders, lifetime: 1676356664, path: , domain: localhost, secure: , html_only mailserver-cypht-1 | [13] => Deleting cookie: name: hm_msgs, lifetime: 1676356664, path: /, domain: localhost, secure: , html_only 1 mailserver-cypht-1 | [14] => Setting cookie: name: hm_msgs, lifetime: 0, path: /, domain: localhost, secure: , html_only 1 mailserver-cypht-1 | [15] => Redirecting to /?page=settings mailserver-cypht-1 | [16] => PHP version 8.2.2 mailserver-cypht-1 | [17] => Zend version 4.2.2 mailserver-cypht-1 | [18] => Peak Memory: 8192 mailserver-cypht-1 | [19] => PID: 12 mailserver-cypht-1 | [20] => Included files: 112 mailserver-cypht-1 | ) mailserver-cypht-1 | NOTICE: PHP message: Array mailserver-cypht-1 | 172.30.0.4 - 14/Feb/2023:07:37:44 +0000 "GET /index.php" 200 mailserver-cypht-1 | ( mailserver-cypht-1 | [0] => Using Hm_PHP_Session with Hm_Auth_IMAP mailserver-cypht-1 | [1] => Using file based user configuration mailserver-cypht-1 | [2] => Using sapi: fpm-fcgi mailserver-cypht-1 | [3] => Request type: HTTP mailserver-cypht-1 | [4] => Request path: / mailserver-cypht-1 | [5] => TLS request: 0 mailserver-cypht-1 | [6] => Mobile request: 0 mailserver-cypht-1 | [7] => Page ID: settings mailserver-cypht-1 | [8] => CACHE backend using: noop mailserver-cypht-1 | [9] => Deleting cookie: name: hm_msgs, lifetime: 1676356664, path: /, domain: localhost, secure: , html_only 1 mailserver-cypht-1 | [10] => TRANSLATION NOT FOUND :Cypht: mailserver-cypht-1 | [11] => PHP version 8.2.2 mailserver-cypht-1 | [12] => Zend version 4.2.2 mailserver-cypht-1 | [13] => Peak Memory: 8192 mailserver-cypht-1 | [14] => PID: 13 mailserver-cypht-1 | [15] => Included files: 68 mailserver-cypht-1 | )_ FYI I am using IMAP auth provided by a container running docker-mailserver.
kerem closed this issue 2026-02-25 21:35:01 +03:00
Author
Owner

@marclaporte commented on GitHub (Feb 19, 2023):

If you supply me a test account (send me info in private), I can assign a junior dev to investigate. You can find me in here: https://app.gitter.im/#/room/#cypht-org_community:gitter.im

<!-- gh-comment-id:1435907780 --> @marclaporte commented on GitHub (Feb 19, 2023): If you supply me a test account (send me info in private), I can assign a junior dev to investigate. You can find me in here: https://app.gitter.im/#/room/#cypht-org_community:gitter.im
Author
Owner

@josaphatim commented on GitHub (Mar 21, 2023):

Screenshot 2023-03-21 at 09 03 10

This is what i get after setting up 2fa module. I faced the same issues. To overcome just ensure.

  • app_data_dir in hm3 ini file is set, folder exists and readable
  • user_settings_dir in hm3 ini file is set, folder exists and writable/readable
  • 2fa.ini is moved to app_data_dir folder
  • Also ensure that when you save settings, logout and then login, settings are not changed otherwise it means there is a problem writing into user_settings_dir.

Thanks.

<!-- gh-comment-id:1477368864 --> @josaphatim commented on GitHub (Mar 21, 2023): > <img width="1420" alt="Screenshot 2023-03-21 at 09 03 10" src="https://user-images.githubusercontent.com/80334370/226537953-5d88e5c8-bd2d-4d3e-af90-6938026d128a.png"> This is what i get after setting up 2fa module. I faced the same issues. To overcome just ensure. - app_data_dir in hm3 ini file is set, folder exists and readable - user_settings_dir in hm3 ini file is set, folder exists and writable/readable - 2fa.ini is moved to app_data_dir folder - Also ensure that when you save settings, logout and then login, settings are not changed otherwise it means there is a problem writing into user_settings_dir. Thanks.
Author
Owner

@knightsg commented on GitHub (Mar 21, 2023):

Thanks, I'll check through my config and do some more testing and let you know how it goes 👍

<!-- gh-comment-id:1478194356 --> @knightsg commented on GitHub (Mar 21, 2023): Thanks, I'll check through my config and do some more testing and let you know how it goes 👍
Author
Owner

@knightsg commented on GitHub (Mar 22, 2023):

@marclaporte It worked! The missing element was ensuring the user settings directory was writable by the fpm process group in my container.

Thank you, I appreciate your help with this!

<!-- gh-comment-id:1478937915 --> @knightsg commented on GitHub (Mar 22, 2023): @marclaporte It worked! The missing element was ensuring the user settings directory was writable by the fpm process group in my container. Thank you, I appreciate your help with this!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cypht#438
No description provided.