You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defvalidate(code: str) ->bool:
ifis_valid:
if (
self.last_used_two_factor_code==code
): # Reject if the code is being reusedraiseUnauthorized("Code not valid.")
else:
self.last_used_two_factor_code=codedb.session.add(self)
db.session.commit()
returnTrueelse:
raiseUnauthorized("Code not valid.")
So when execute. At beginning when user try to confirm two_factor, there is a database insertion conflict. auth object already inserted to database during validate. Then after that when we try to update auth enabled attribute and insert again:
I think I see what you mean - bad place for that logic to be really. I haven't encountered this actually raising an error though. But, we aren't testing against MySQL, so possible it causes an issue there.
Have you got a minimal example which causes an error by any chance?
Gave this a bit more thought. I think the right solution here is to bump the last used code portion out of the database, and use dogpilecache or similar to handle tracking the last used codes. That should allow us to avoid the scenario described here, and also allow for a ttl on the last used codes, without causing us issues because of our use of uwsgi.
And i also found another issue with insert
two_factor_auth
to databaseThis code block in
user_setting.py
and
validate()
function declared:So when execute. At beginning when user try to confirm two_factor, there is a database insertion conflict.
auth
object already inserted to database during validate. Then after that when we try to update auth enabled attribute and insert again:That will throw error. because auth object already gone
Originally posted by @hprobotic in #1170 (comment)
The text was updated successfully, but these errors were encountered: