Huh, I thought using fancyLog( { something in here } ... ) would only echo to the "something in here", am I wrong?
Well, if anything, it stores it in the serverside logs, so those could be pulled by someone attacking the server. But if your server gets hacked that badly, you have bigger problems. So I suppose it's less of an issue.
I thought about this, but I've no idea where I could store it. On a related note, if it were to store/change, where could those users access it?
Store the secret in plaintext, like in pdata. The QR code needs to only be shown once, then never again once you verify the TOTP app was set up properly.
You should never need to change the TOTP secret unless an account is compromised, in which case you should probably have a re-generate button or command of some sort available for other admins to run.
My suggestion for the TOTP flow:
- Staff member joins server
- If no TOTP secret in database, generate one and show a popup with a QR code and a code box, preferably with some instructions on how to set up TOTP with an app
- If TOTP key, show a simple code box
- Once code is verified, add user to staff rank
Again, if an account is compromised, you could have a command to invalidate (unset) the TOTP secret in your database, which causes the user to go through the first time setup again.