Browse Source

Add missing User.flake_id generation on insert event

pull/334/head
squeaky otter 2 years ago
parent
commit
b67fda0802
Signed by: dashie GPG Key ID: C2D57B325840B755
2 changed files with 8 additions and 0 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +7
    -0
      api/models.py

+ 1
- 0
CHANGELOG.md View File

@ -56,3 +56,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Waveform JSON generation through a .dat now use the right pixels per second; avoid huge waveforms datas for long tracks (#179)
- Flake ID generation have been rewritten and should be good now
- Flask Security email confirmation is now respected on registration and login workflows
- User flake_id are now properly generated on insert

+ 7
- 0
api/models.py View File

@ -203,6 +203,13 @@ class User(db.Model, UserMixin):
event.listen(User.name, "set", User.generate_slug, retval=False)
@event.listens_for(User, "after_insert")
def generate_user_flakeid(mapper, connection, target):
if not target.flake_id:
flake_id = uuid.UUID(int=current_app.flake_id.get())
connection.execute(User.__table__.update().where(User.__table__.c.id == target.id).values(flake_id=flake_id))
user_datastore = SQLAlchemyUserDatastore(db, User, Role)


Loading…
Cancel
Save