-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: anonymiser les urls de profil des utilisateurs (#832)
## Description #### fix 1⚠️ Le `username` est utilisé dans l'url de la page de profil des utilisateurs. Il ne doit contenir aucune donnée d'identification. 🦺 Corriger l'hydratation du `username` des utilisateurs créés lors de la première connection avec le lien magique #### fix 2⚠️ Les utilisateurs créés via le magic link, qui se connectent plus tard via `ProConnect` doivent être reconnus comme existant. 🦺 Mettre à jour l'`identity_provider` de ces utiliisateurs lors de leur première connection avec `ProConnect` #### fix 3 🦺 mettre à jour les `username` égaux aux `emails` avec un `uuid4` ## Type de changement 🪲 Correction de bug (changement non cassant qui corrige un problème). 🚧 technique --------- Co-authored-by: leo-naeka <[email protected]>
- Loading branch information
1 parent
cd4dede
commit 6f03e8f
Showing
9 changed files
with
112 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Generated by Django 5.0.9 on 2024-11-26 13:03 | ||
|
||
from django.db import migrations | ||
|
||
import lacommunaute.users.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("users", "0003_alter_user_identity_provider"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelManagers( | ||
name="user", | ||
managers=[ | ||
("objects", lacommunaute.users.models.UserManager()), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Generated by Django 5.0.9 on 2024-11-25 15:15 | ||
|
||
from uuid import uuid4 | ||
|
||
from django.db import migrations | ||
from django.db.models import F | ||
|
||
from lacommunaute.users.models import User | ||
|
||
|
||
def cleanup_email_in_username(apps, schema_editor): | ||
users_to_migrate = User.objects.filter(username=F("email")) | ||
|
||
while batch_users := users_to_migrate[:1000]: | ||
for user in batch_users: | ||
user.username = str(uuid4()) | ||
User.objects.bulk_update(batch_users, ["username"]) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("users", "0004_alter_user_managers"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(cleanup_email_in_username, migrations.RunPython.noop), | ||
] | ||
|
||
elidable = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import re | ||
|
||
from lacommunaute.users.models import User | ||
|
||
|
||
def test_create_user_without_username(db): | ||
user = User.objects.create_user(email="[email protected]") | ||
assert re.match(r"^[a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12}$", user.username) | ||
assert user.email == "[email protected]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters