-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Changing some fields in the finger.json source seems to create duplicate users. I'm not alert enough to find the actual problem at the moment, but we need to investigate this. I think some change is needed here:
fingerweb/app/finger/models.py
Lines 138 to 168 in d5992e3
| # We need to uniqily identify a member in finger.json and map it to Member. | |
| # Use the special key fingerweb_identifier if found in finger.json, if not | |
| # found use the username. | |
| # | |
| # We have members without identifier and usernames, for these use the | |
| # following fallbacks: | |
| # - User provided email address | |
| # - Stacken email adress (will be generated from the username (if it's exists)) | |
| # - First and last name | |
| # | |
| # If the above causes conflicts, add and fingerweb_identifier key to the member. | |
| if fields["identifier"]: | |
| member, _ = self.update_or_create(identifier__exact=fields["identifier"], defaults=fields) | |
| else: | |
| user_from_db = User.objects.filter(username__exact=user.get("användarnamn")).first() | |
| if self.is_valid_user(user) and user_from_db: | |
| member, _ = self.update_or_create(id=user_from_db.id, defaults=fields) | |
| elif "@" in fields.get("email", ""): | |
| member, _ = self.update_or_create(email__exact=fields["email"], defaults=fields) | |
| else: | |
| member, _ = self.update_or_create( | |
| first_name__exact=fields["first_name"], last_name__exact=fields["last_name"], defaults=fields | |
| ) | |
| # Create and/or update an account for the member | |
| if fields.get("has_signed") and self.is_valid_user(user): | |
| user_fields = { | |
| "member": member, | |
| "date_joined": fields.get("date_joined"), | |
| } | |
| User.objects.update_or_create(username=user.get("användarnamn"), defaults=user_fields) |
Metadata
Metadata
Assignees
Labels
No labels