user742736
user742736

Reputation: 2729

Rest API: Email Activation

I'm still new to REST API Development.

I am developing this in Laravel if that helps.

What is the best practice for user email activation? As in how would the url look like?

Is it something like this api.domain.com/activation/"token"? and would I be using the PUT method?

I am a bit confused on how you would implement the User activation with email.

To add a user I am using the POST method to api.domain.com/users.

On success the user will be sent an email with the activation link and token.

Edit:

Or should I create a new route account/activation which will point to the "ActivationController" resourceful controller and then use the PUT method to activate the account.

Upvotes: 1

Views: 903

Answers (2)

galusben
galusben

Reputation: 6372

Send the user to an HTML page, meaning the url in the email is not the url for the API, but will just point to your UI, and the token will be a query/path parameter on the url. The HTML page will hold javascript code that will invoke the REST endpoint for you using AJAX. The javascript code will take the token from the url.

And yes, I know this is old, but I got to this page when I was looking for answer for a similar problem.

Upvotes: 1

chrisbjr
chrisbjr

Reputation: 628

If you're sticking to "best practices", yes, PUT would make sense. However, since the users will be clicking on a link from their email, I don't think there's a way to change the HTTP request method for that when they are redirected by the browser. The GET method would be your best bet - and, yes, your token should be in the URL as well.

Upvotes: 1

Related Questions