Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

otp_secret is not being saved for preexisting data #1

Closed
yininge opened this issue Jun 8, 2019 · 2 comments
Closed

otp_secret is not being saved for preexisting data #1

yininge opened this issue Jun 8, 2019 · 2 comments

Comments

@yininge
Copy link
Contributor

yininge commented Jun 8, 2019

I have a User table that has preexisting data, and I start using otp-jwt recently.
It is not working at the beginning because otp_secret column is always empty for preexisting User record

The active record does give the User record a default otp_secret

def setup_otp
self.otp_secret ||= ROTP::Base32.random_base32
self.otp_counter ||= 0

My workaround is to go through each user record and save the default otp_secret

User.all.each do |u|
  u.save()
end

Not sure whether we can make it better by updating the documentation, or always save the default secret if there are otp_secret column is empty

@stas
Copy link
Owner

stas commented Jun 10, 2019

@yininge, thanks for reporting this, you're right, the otp_secret values need to be stored first.

I like the documentation suggestion. If you have time, I'll be happy to merge an update for the readme, if not, I'll try to do it in the next days.

🙇‍♂️

@stas
Copy link
Owner

stas commented Jun 12, 2019

Closed as part of #2

@stas stas closed this as completed Jun 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants