Add username to the TOTP secret name

This works around issue in FreeOTP app which crashed when
the same name is used.

https://github.com/freeotp/freeotp-ios/issues/69
https://github.com/freeotp/freeotp-android/issues/69
This commit is contained in:
Girish Ramakrishnan
2018-06-04 15:54:34 -07:00
parent 321f11c644
commit ab80cc9ea1

View File

@@ -565,7 +565,7 @@ function setTwoFactorAuthenticationSecret(userId, callback) {
if (result.twoFactorAuthenticationEnabled) return callback(new UsersError(UsersError.ALREADY_EXISTS));
var secret = speakeasy.generateSecret({ name: `Cloudron (${config.adminFqdn()})` });
var secret = speakeasy.generateSecret({ name: `Cloudron ${config.adminFqdn()} (${result.username})` });
userdb.update(userId, { twoFactorAuthenticationSecret: secret.base32, twoFactorAuthenticationEnabled: false }, function (error) {
if (error) return callback(new UsersError(UsersError.INTERNAL_ERROR, error));