From b246c8e0f254fc75c637bc2bd396f9c613e6759a Mon Sep 17 00:00:00 2001 From: LouisLam Date: Fri, 1 Oct 2021 00:23:18 +0800 Subject: [PATCH] Fix 2fa for iOS Google authenticator (#486) --- server/server.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/server.js b/server/server.js index 2384acf57..0fbe8325b 100644 --- a/server/server.js +++ b/server/server.js @@ -303,6 +303,12 @@ exports.entryPage = "dashboard"; if (user.twofa_status == 0) { let newSecret = await genSecret(); let encodedSecret = base32.encode(newSecret); + + // Google authenticator doesn't like equal signs + // The fix is found at https://github.com/guyht/notp + // Related issue: https://github.com/louislam/uptime-kuma/issues/486 + encodedSecret = encodedSecret.toString().replace(/=/g, ""); + let uri = `otpauth://totp/Uptime%20Kuma:${user.username}?secret=${encodedSecret}`; await R.exec("UPDATE `user` SET twofa_secret = ? WHERE id = ? ", [