Bug 33904: Fix 2FA registration when library name has non-latin characters
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 6 Jun 2023 08:42:20 +0000 (10:42 +0200)
committerTomas Cohen Arazi <tomascohen@theke.io>
Fri, 9 Jun 2023 11:28:58 +0000 (08:28 -0300)
commitdeeb5ebdbd59956f5f6cf1bfa989ef41c9af9720
treee272ba2e09a0d21f82c82193d817d5ff10f91b5c
parentdfed7f235d2e079743a74bb2791db2d4ebd63b1d
Bug 33904: Fix 2FA registration when library name has non-latin characters

If the library name contains non-latin characters, the 2FA registration
process will fail with a JS alert coming from a 500 server-side.

The problem is that Auth::GoogleAuth is expecting an already UTF8 encoded string.
We should set the encoding correctly to make Auth::GoogleAuth deal with
the URL escaping internally correctly, then decode on our own (in the
REST API controller)

Test plan:
* Modify your logged in library name and add some non-latin characters
(eg. "my ❤ library")
* Turn on TwoFactorAuthentication
* Go to your account > More > Manage 2FA
* Click the enable button
=> Notice that you see the QR code and that both "issuer" and "key id"
entries display the library name correctly.
* Test the whole 2FA process, confirm that the library name is correctly
displayed on the app you are using.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Koha/Auth/TwoFactorAuth.pm
Koha/REST/V1/TwoFactorAuth.pm