Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: User unsubscribe 286 #288

Merged
merged 1 commit into from
Aug 27, 2018
Merged

WIP: User unsubscribe 286 #288

merged 1 commit into from
Aug 27, 2018

Conversation

groovecoder
Copy link
Member

This is a very ugly start but I'd like to get a review.

@groovecoder groovecoder requested a review from pdehaan August 24, 2018 18:55
@groovecoder groovecoder force-pushed the user-unsubscribe-286 branch from 81ad5fa to ca55824 Compare August 24, 2018 18:56


async function postUnsubscribe(req, res) {
const unSubscribedUser = await DB.removeSubscriber(req.body.token, req.body.emailHash);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: This should be unsubscribedUser or the method should be postUnSubscribe(). It feels like we're mixing styles here slightly.

db/DB.js Outdated
"verification_token": token,
"sha1": emailSha1,
});
return res[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

I know we've discussed briefly in the past, but should this be res[0] or should we try appending a .first() to the above SELECT query.

@@ -193,6 +193,11 @@ const postData = (url, data = {}) => {
};

function handleFormSubmits(formEvent) {
console.log("handleFormSubmits, formEvent: ", formEvent);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove debug console.log()

@@ -27,5 +27,6 @@
</tr>
</table>

You got this email because you signed up at {{ AppConstants.SERVER_URL }}. <a href="{{ unsubscribeUrl }}" target="_blank">Unsubscribe</a>
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure if we need the "noreferrer" stuff here, since I think this is coming from an email (but I can't imagine it hurts).

<div class="unsubscribe-message-wrapper">
<div class="unsubscribe-message">
{{#if unsubscribed }}
<h4>You have unsubscribed.</h4>
Copy link
Contributor

Choose a reason for hiding this comment

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

May need somebody to verify wording here. Have I unsubscribed, or have I been unsubscribed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah the email and page text and designs are all just WIP right now. This PR is just to get them into place so @lesleyjanenorton can make them better.

<h4>You have unsubscribed.</h4>
{{ else }}
<h4>Are you sure you want to unsubscribe?</h4>
<form action="/user/unsubscribe" method="post" id="unsubscribe-form">
Copy link
Contributor

Choose a reason for hiding this comment

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

May need clarification here on if we need to add the data-no-csrf novalidate flags here. I noticed we have them in:

<form action="/scan" class="email-scan form-group" method="post" data-no-csrf novalidate>

<form action="/user/add" id="subscribe-form" class="form-group" method="post" novalidate data-no-csrf>

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah the email and page text and designs are all just WIP right now. This PR is just to get them into place so @lesleyjanenorton can make them better.

@groovecoder groovecoder force-pushed the user-unsubscribe-286 branch 2 times, most recently from fdd9f6c to f88d34b Compare August 26, 2018 14:29
@groovecoder
Copy link
Member Author

All comments addresses except the couple that will be fixed with final email designs & HTML.

@pdehaan
Copy link
Contributor

pdehaan commented Aug 26, 2018

Not sure if you want both commits in this PR, or if you want to remove first one to avoid merging in the refresh breaches code as well

@groovecoder groovecoder force-pushed the user-unsubscribe-286 branch from f88d34b to 4455f95 Compare August 26, 2018 14:57
@groovecoder
Copy link
Member Author

Removed the breaches endpoint commit.

const sha1 = getSha1(email);

return await this._getSha1EntryAndDo(sha1, async aEntry => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess outside of the scope of this PR, but...
Why does it take 2 queries to delete a user? By proxying this._getSha1EntryAndDo(sha1), we call knex("subscribers").where("sha1", sha1), and then here we requery the same table by knex("subscribers").where("id", "=", aEntry.id).del()

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, another refactor I'd like to perform is to remove the _getSha1EntryAndDo function completely.

@groovecoder groovecoder merged commit 5365818 into master Aug 27, 2018
@groovecoder groovecoder deleted the user-unsubscribe-286 branch August 27, 2018 14:44
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.

2 participants