Accepting an invitation gives the role to a user record looked up by email

Aperta Adatta ai principianti
#6,409 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
django, python

Direzione di ricerca

Leggi Invitation.accept in contentcuration/contentcuration/models.py, intorno alle righe 3701–3710, e segui il modo in cui il ruolo viene assegnato all’utente selezionato. Inizia eseguendo o individuando i test di accettazione degli inviti, poi aggiungi test di regressione per i casi di email duplicata e di assenza di un account attivo. Il lavoro è terminato quando l’account attivo con l’email esatta riceve il ruolo e l’assenza di un account attivo restituisce 400 senza modificare gli editor o i visualizzatori del canale.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

DEV: backend

Overview

Invitation.accept looks the invited user up again by email, case-insensitively, with no filter on active or deleted users and no ordering. When several user records share the email in different case, the role can go to an inactive or deleted record instead of the user who accepted. When an admin accepts an invitation for an email that has no account, accept adds None as an editor and the request fails with IntegrityError.

Complexity: Low
Target branch: hotfixes

Context
  • Invitation.accept starts with User.objects.filter(email__iexact=self.email).first().
  • Reproduced:
    • Active user [email protected] accepts an invitation. An older inactive record [email protected] becomes the channel editor, and the accepting user doesn't.
    • An admin accepts an invitation for an email with no account, and gets 500 with IntegrityError on a null user_id.
  • Related: #4779, #3050. #6406 backports the invitee-only accept check to hotfixes. #6405 depends on the same lookup on unstable.
The Change
  • Accepting should give the role to the active account whose email exactly matches the invitation's. #5893 lets admins accept on an invitee's behalf, so the accepting user isn't always the invitee.
  • Accepting an invitation with no matching active account should fail with a validation error and change nothing.
Acceptance Criteria
General
  • When other records share the invitee's email in a different case, the active account with the exact email gets the role and no other record does.
  • Accepting an invitation whose email has no active account returns 400 and leaves the channel's editors and viewers unchanged.
Testing
  • Both reproduced cases in Context have regression tests.

AI usage

I scoped the audit. Claude Code found and reproduced these failures and drafted this issue.

Lingua principale
Python
Stelle
212
Fork
321
Merge medio
1g 7h
PR unite (30g)
14

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di learningequality/studio

Tutte le issue di learningequality/studio

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.