[GH-ISSUE #226] Can't reactivate twofactor_gateway #52

Closed
opened 2026-02-26 05:32:43 +03:00 by kerem · 7 comments
Owner

Originally created by @binford6000 on GitHub (Apr 17, 2019).
Original GitHub issue: https://github.com/nextcloud/twofactor_gateway/issues/226

I deactivated twofactor_gateway some days ago and wanted to reactivate it. When i enter my identification it says: "Could not verify your code. Please try again". This could be found in the log:

`[index] Error: UnexpectedValueException: Only integers, floats and strings are allowed as value at <>

  1. /var/www/cloud/apps/twofactor_gateway/lib/Service/Gateway/Telegram/Gateway.php line 107
    setUserValue("admin", "twofactor_gateway", "telegram_chat_id", null)
  2. /var/www/cloud/apps/twofactor_gateway/lib/Service/Gateway/Telegram/Gateway.php line 75
    getChatId(OC\User\User {}, Telegram\Bot\Api {}, 123456789)
  3. /var/www/cloud/apps/twofactor_gateway/lib/Service/SetupService.php line 92
    send(OC\User\User {}, "123456789", "253871 is your ... .")
  4. /var/www/cloud/apps/twofactor_gateway/lib/Controller/SettingsController.php line 90
    startSetup(OC\User\User {}, "telegram", "123456789")
  5. /var/www/cloud/lib/private/AppFramework/Http/Dispatcher.php line 166
    startVerification("telegram", "123456789")
  6. /var/www/cloud/lib/private/AppFramework/Http/Dispatcher.php line 99
    executeController(OCA\TwoFactorGat ... {}, "startVerification")
  7. /var/www/cloud/lib/private/AppFramework/App.php line 118
    dispatch(OCA\TwoFactorGat ... {}, "startVerification")
  8. /var/www/cloud/lib/private/AppFramework/Routing/RouteActionHandler.php line 47
    main("OCA\TwoFactorG ... r", "startVerification", OC\AppFramework\ ... {}, {gateway: "teleg ... "})
  9. <>
    __invoke({gateway: "teleg ... "})
  10. /var/www/cloud/lib/private/Route/Router.php line 297
    call_user_func(OC\AppFramework\ ... {}, {gateway: "teleg ... "})
  11. /var/www/cloud/lib/base.php line 987
    match("/apps/twofactor ... t")
  12. /var/www/cloud/index.php line 42
    handleRequest()

POST /apps/twofactor_gateway/settings/telegram/verification/start
from 91.67.178.10 by admin at 2019-04-17T19:28:16+00:00`

What can i do to reactivate twofactor_gateway?
Kind regards,
Sebastian

Originally created by @binford6000 on GitHub (Apr 17, 2019). Original GitHub issue: https://github.com/nextcloud/twofactor_gateway/issues/226 I deactivated twofactor_gateway some days ago and wanted to reactivate it. When i enter my identification it says: "Could not verify your code. Please try again". This could be found in the log: `[index] Error: UnexpectedValueException: Only integers, floats and strings are allowed as value at <<closure>> 0. /var/www/cloud/apps/twofactor_gateway/lib/Service/Gateway/Telegram/Gateway.php line 107 setUserValue("admin", "twofactor_gateway", "telegram_chat_id", null) 1. /var/www/cloud/apps/twofactor_gateway/lib/Service/Gateway/Telegram/Gateway.php line 75 getChatId(OC\User\User {}, Telegram\Bot\Api {}, 123456789) 2. /var/www/cloud/apps/twofactor_gateway/lib/Service/SetupService.php line 92 send(OC\User\User {}, "123456789", "253871 is your ... .") 3. /var/www/cloud/apps/twofactor_gateway/lib/Controller/SettingsController.php line 90 startSetup(OC\User\User {}, "telegram", "123456789") 4. /var/www/cloud/lib/private/AppFramework/Http/Dispatcher.php line 166 startVerification("telegram", "123456789") 5. /var/www/cloud/lib/private/AppFramework/Http/Dispatcher.php line 99 executeController(OCA\TwoFactorGat ... {}, "startVerification") 6. /var/www/cloud/lib/private/AppFramework/App.php line 118 dispatch(OCA\TwoFactorGat ... {}, "startVerification") 7. /var/www/cloud/lib/private/AppFramework/Routing/RouteActionHandler.php line 47 main("OCA\\TwoFactorG ... r", "startVerification", OC\AppFramework\ ... {}, {gateway: "teleg ... "}) 8. <<closure>> __invoke({gateway: "teleg ... "}) 9. /var/www/cloud/lib/private/Route/Router.php line 297 call_user_func(OC\AppFramework\ ... {}, {gateway: "teleg ... "}) 10. /var/www/cloud/lib/base.php line 987 match("/apps/twofactor ... t") 11. /var/www/cloud/index.php line 42 handleRequest() POST /apps/twofactor_gateway/settings/telegram/verification/start from 91.67.178.10 by admin at 2019-04-17T19:28:16+00:00` What can i do to reactivate twofactor_gateway? Kind regards, Sebastian
Author
Owner

@ChristophWurst commented on GitHub (Apr 17, 2019):

Apparently an invalid value type is passed as parameter. I assume it is null.

In the case of Telegram this is a bit of a problem because the /start message is only sent once.

<!-- gh-comment-id:484232012 --> @ChristophWurst commented on GitHub (Apr 17, 2019): Apparently an invalid value type is passed as parameter. I assume it is `null`. In the case of Telegram this is a bit of a problem because the `/start` message is only sent once.
Author
Owner

@ChristophWurst commented on GitHub (Apr 17, 2019):

This won't help solving your issue but it's a known bug/limitation: github.com/nextcloud/twofactor_gateway@95f36e7bbf/lib/Service/Gateway/Telegram/Gateway.php (L104)

<!-- gh-comment-id:484232211 --> @ChristophWurst commented on GitHub (Apr 17, 2019): This won't help solving your issue but it's a known bug/limitation: https://github.com/nextcloud/twofactor_gateway/blob/95f36e7bbfaf2d04ffd3c3c3fa2b22352e20bf18/lib/Service/Gateway/Telegram/Gateway.php#L104
Author
Owner

@ChristophWurst commented on GitHub (Apr 17, 2019):

This is likely related to https://github.com/nextcloud/twofactor_gateway/issues/110. Unfortunately I have not found the time yet to work on that as this app is low on my priority list, so any help would be highly appreciated 🙌

<!-- gh-comment-id:484232621 --> @ChristophWurst commented on GitHub (Apr 17, 2019): This is likely related to https://github.com/nextcloud/twofactor_gateway/issues/110. Unfortunately I have not found the time yet to work on that as this app is low on my priority list, so any help would be highly appreciated :raised_hands:
Author
Owner

@parreitu commented on GitHub (Apr 26, 2019):

Hi
I've made a test. I've edited the getChatId function of this file

https://github.com/nextcloud/twofactor_gateway/blob/95f36e7bbfaf2d04ffd3c3c3fa2b22352e20bf18/lib/Service/Gateway/Telegram/Gateway.php#L86

Replacing

$chatId = $this->config->getUserValue($user->getUID(), 'twofactor_gateway', 'telegram_chat_id', null);

by this line (suppose that 999999 is my chat_id)

$chatId = 999999

With this change, all is ok. I can configure the gateway, I get the verification code on my telegram APP , I can deactivate and activate again the twofactor_gateway, ..., all is OK.

All the problems related by @Dretech in this issue #110 appear to be solved.

So, in consequence, I think that the problem is in this line, it isn't getting the number (our chat_id) that we previously have introduced in the verify box

$chatId = $this->config->getUserValue($user->getUID(), 'twofactor_gateway', 'telegram_chat_id', null);

I don't know how to make this changes in PHP, but it could be a good clue to solve the issue.

<!-- gh-comment-id:487092287 --> @parreitu commented on GitHub (Apr 26, 2019): Hi I've made a test. I've edited the **getChatId** function of this file [https://github.com/nextcloud/twofactor_gateway/blob/95f36e7bbfaf2d04ffd3c3c3fa2b22352e20bf18/lib/Service/Gateway/Telegram/Gateway.php#L86](https://github.com/nextcloud/twofactor_gateway/blob/95f36e7bbfaf2d04ffd3c3c3fa2b22352e20bf18/lib/Service/Gateway/Telegram/Gateway.php#L86) Replacing **$chatId = $this->config->getUserValue($user->getUID(), 'twofactor_gateway', 'telegram_chat_id', null);** by this line (suppose that 999999 is my chat_id) **$chatId = 999999** With this change, all is ok. I can configure the gateway, I get the verification code on my telegram APP , I can deactivate and activate again the twofactor_gateway, ..., all is OK. All the problems related by @Dretech in this issue #110 appear to be solved. So, in consequence, I think that the problem is in this line, it isn't getting the number (our chat_id) that we previously have introduced in the **verify box** **$chatId = $this->config->getUserValue($user->getUID(), 'twofactor_gateway', 'telegram_chat_id', null);** I don't know how to make this changes in PHP, but it could be a good clue to solve the issue.
Author
Owner

@binford6000 commented on GitHub (Apr 26, 2019):

Hi parreitu,
that works for me, too! Made my day ;-)
Sebastian

<!-- gh-comment-id:487194005 --> @binford6000 commented on GitHub (Apr 26, 2019): Hi parreitu, that works for me, too! Made my day ;-) Sebastian
Author
Owner

@Dretech commented on GitHub (May 7, 2019):

Hello Parreitu,

You found the cause why the Telegram 2fa app is not working in Nextcloud. When I change the chatid by the way you described, the app is working! Thanks.

@ChristophWurst can you change line 86 of /lib/Service/Gateway/Telegram/Gateway.php in a way that this line uses the user id entered in the web interface?

Dretech

<!-- gh-comment-id:489990401 --> @Dretech commented on GitHub (May 7, 2019): Hello Parreitu, You found the cause why the Telegram 2fa app is not working in Nextcloud. When I change the chatid by the way you described, the app is working! Thanks. @ChristophWurst can you change line 86 of /lib/Service/Gateway/Telegram/Gateway.php in a way that this line uses the user id entered in the web interface? Dretech
Author
Owner

@ChristophWurst commented on GitHub (May 7, 2019):

It's on my todo!

<!-- gh-comment-id:490084579 --> @ChristophWurst commented on GitHub (May 7, 2019): It's on my todo!
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/twofactor_gateway-nextcloud#52
No description provided.