Skip to content

User can set primary email

Created by: ryanslade

Currently a user's primary email address is chosen using the following logic:

The oldest email associated with the user, preferring a verified email to an
unverified email.

We want to allow a user to choose their own primary address.

We need to add an is_primary flag to the user_emails table and migrate using the logic above.

After that the following rules apply:

  • The first email added will automatically be flagged as the primary
  • A user cannot delete their primary address
  • Only a verified address can be set by the user as primary
  • Only one primary address is allowed per user

We need to add a graphql mutation to set the primary address. Only the owner or site admin can perform this action:

setUserEmailPrimary(user: ID!, email: String!): EmptyResponse!