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

Aberta Para iniciantes
#6,409 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
76/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
django, python

Direção de pesquisa

Leia Invitation.accept em contentcuration/contentcuration/models.py, por volta das linhas 3701–3710, e acompanhe como a função atribui a função ao usuário selecionado. Comece executando ou localizando os testes de aceitação de convites e, em seguida, adicione cobertura de regressão para os casos de e-mail duplicado e de ausência de uma conta ativa. O trabalho estará concluído quando a conta ativa com o e-mail exato receber a função e a ausência de uma conta ativa retornar 400 sem alterar os editores ou visualizadores do canal.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Python
Estrelas
212
Forks
321
Merge médio
1d 7h
PRs com merge (30d)
14

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de learningequality/studio

Todas as issues de learningequality/studio

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.