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
  1. 1
      CHANGELOG.md
  2. 7
      api/models.py

1
CHANGELOG.md

@ -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
api/models.py

@ -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