ITI / searcch

SEARCCH Hub Frontend
https://searcch.cyberexperimentation.org/
BSD 3-Clause "New" or "Revised" License
3 stars 6 forks source link

Add user-facing auto claim email handling #189

Closed carboxylman closed 1 year ago

carboxylman commented 1 year ago

We need two new frontend features, related to backend https://github.com/ITI/searcch-backend/issues/95:

brian-at-sri commented 1 year ago

The URL I chose for the opt out in the backend is \<host>/v1/email/opt_out. It has two query params: email and key. It returns 404 if the email and matching key are not found, or 200 if successful.

ckouder commented 1 year ago

Thank you Brain, this is really helpful. Is it OK to assume that the opt-out button in the email contains email and key? Since to opt-out i need to get those params.

brian-at-sri commented 1 year ago

Yes. My assumption is that you'll create a frontend endpoint which will be the actual destination for the link in the email, and that frontend endpoint will call this one. I will include the email and key as query params, unless you prefer them in some other format.

brian-at-sri commented 1 year ago

Also then endpoint returns json message.

{'message': 'opted out of future communication'} on success, and {'message': 'email or key not found'} on 404.

ckouder commented 1 year ago

ok i created a frontend page in at <host>/optout here https://github.com/ITI/searcch/tree/189a-optout-ui. The webpage will automatically call your API endpoint when it mounts. I also navigates a user to home page if he doesn't have email or key params. Let me know your thoughts!

brian-at-sri commented 1 year ago

@ckouder For the auto claim, do you want to just look for the same email and key query params on the artifact page? Or perhaps it's better to have a url like /artifact/{id}/claim?key=''&email=''.

The requirements as I understand them:

I suppose I probably need to provide an endpoint to verify the key.

brian-at-sri commented 1 year ago

Slight revision, it will return 401 Unauthorized instead of 404 if the key is not found.

ckouder commented 1 year ago

There is an existing endpoint artifact/request/owner/<artifact-group-id> for the data POST by standard claim request UI. Can we do GET artifact/request/owner/<artifact-group-id>?key=''&email='' for the magic code?

brian-at-sri commented 1 year ago

That works for me.

brian-at-sri commented 1 year ago

@ckouder How is the opt out handler coming along? Is it ready for testing? I tried checking out branch 189a-optout-ui and calling the optout endpoint, but I get the following error.

An error occurred
Cannot read properties of undefined (reading 'index')

I also don't see my backend endpoint being called.

ckouder commented 1 year ago

@brian-at-sri Sorry my bad! I forget to add opt out endpoint on my end. It should be fixed by now. Would you please try again?

brian-at-sri commented 1 year ago

I now receive a 404 response. The backend is still not being called. The backend endpoint is as follows:

<backend_host>/v1/email/opt_out

ckouder commented 1 year ago

Okay got it. just pushed another commit. Frontend should call /v1/email/opt_out by now. I thought you are using /v1/optout for backend as well

brian-at-sri commented 1 year ago

Oh right, I forgot I made it a POST endpoint. Can you make that change as well?

ckouder commented 1 year ago

No worries! I got it. Let's do pair coding sometime if you'd like. I never did it before but I believe it would reduce some communication problems... I'm working on claim-ownership ui now. How can I use that backend endpoint for magic code? what data does backend expecting from my end? POST or GET?

brian-at-sri commented 1 year ago

I haven't created a backend endpoint for the claim-ownership code. I'm not sure what would be best. I could simply whip up an endpoint that would return true/false if the code was valid, then you could go through the normal claim process. Or we could extend the existing claim process to accept the the key code.

I'd love to help but I've actually overshot my budget on SEARCCH and need to back off on spending. I think for now simply opening a page with the existing claim dialog opened will be sufficient in the short term. We can attempt an automatic claim using the key if there is budget for it later.

carboxylman commented 1 year ago

Finished in https://github.com/ITI/searcch/commit/d542716902f0c95d244d5191d32c46b0b532175c and https://github.com/ITI/searcch-backend/commit/f5e06e35c163fb080b78e9d09bf0c694f63c598d .