Skip to content

Conversation

@leannecornish-ft
Copy link
Contributor

@leannecornish-ft leannecornish-ft commented Apr 28, 2025

Describe your changes

We have found a bug that causes users that have previously had an FT account to comment with their old coral account. We will be adding an additional check to the auth endpoint in next-comments-api, which will return a 403 when an old coral account is found. This PR checks for this status and returns a user-friendly error to the client.

Additional context

JIRA ticket Figma design
Parent: CI-2823
Sub: CI-2827

Checklist before requesting a review

  • I have applied percy label for o-[COMPONENT] or chromatic label for o3-[COMPONENT] on my PR before merging and after review. Find more details in CONTRIBUTING.md
  • If it is a new feature, I have added thorough tests.
  • I have updated relevant docs.
  • I have updated relevant env variables in Doppler.

@notlee notlee temporarily deployed to origami-webs-ci-2827-ex-5uaaec April 28, 2025 16:06 Inactive
Comment on lines +331 to +336
const messageForEmailInUse = `
<h3>There is a problem configuring your commenting account</h3>
<p>
Please contact ${this.options.linkContact ? `<a class="linkContact" href='${this.options.linkContact}'>Customer Care</a>` : `Customer Care`} referencing issue code E403.
</p>
`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought: not your fault but all these consts instantiated and not even used are a missed optimisation. Everytime a const is create it's using memory and then taking resources because of the Garbage collection that needs to follow. See comment below...

} else if (this.isTrialist) {
customMessageContainer.innerHTML = messageForTrial;
} else if (this.emailInUse) {
customMessageContainer.innerHTML = messageForEmailInUse;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per my previous comment, this could code could be structured differently...

Suggested change
customMessageContainer.innerHTML = messageForEmailInUse;
customMessageContainer.innerHTML = `<h3>There is a problem configuring your commenting account</h3>
<p>
Please contact ${this.options.linkContact ? `<a class="linkContact" href='${this.options.linkContact}'>Customer Care</a>` : `Customer Care`} referencing issue code E403.
</p>
`;

Comment on lines +406 to +412
user_type: this.emailInUse
? 'registered-email-in-use'
: this.isTrialist
? 'trialist'
: this.isRegistered
? 'registered'
: 'anonymous'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought: Again, this was like this before...it would likely benefit of creating a model and use that pushing the logic in the model and keep this part dumb till you reach something like the following:

user_type: user.type << A user model


// some users have coral accounts associated to old FT accounts that are using the same email address
// we need to remove this email before they can sign in to the new account
if (response.status === 403) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought: Using only status code may not be a very scalable solution. What if tomorrow we introduce another condition that generates a 403 but we want a different message.
We could share the error code as part of a payload in the response.
Pseudo response...

    status-code: 403
    payload: {
       error-code: `CommentError403`, << Or whatever
       }

In this way is easy to track the error between customer care, frontend and backend, you can even search the repos for this.

@leannecornish-ft
Copy link
Contributor Author

Closing in favour of #2102

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants