Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the REST way to verify an email?

Tags:

When a user register to my web application I send an email to verify his inbox. In the email there are a link to a resource like this:

GET /verify/{token}

Since the resource is being updated behind the scenes, doesn't it break the RESTful approach?

How can I do it in a RESTful manner?

like image 798
user3482682 Avatar asked Sep 25 '16 18:09

user3482682


People also ask

Is there a way to verify an email address?

However, the best and quickest way to validate an email address is to use an email checker that looks at the address to see if it has the correct syntax and that mail can be delivered to the address.

How can I verify my email without sending an email?

The best and most recommended ways to verify an email address without sending an email are: Email verifier tools: Use an email verification service to check if the given address is valid or not. Just google 'Email Verifier,' and many free and paid options will come up.

How do I verify my email on Gmail?

Sign in to your email to verify your account While you're creating your account, you'll get an email from Google. Open the email and find the verification code. To finish creating your account, enter the verification code when prompted.

What does verifying an email mean?

Email verification is the process of checking and authenticating emails that you've been given to ensure that they're authentic and that they're likely to connect you to a real person (or, at the least, a real email account of an organization).


2 Answers

What you are talking about is not REST. REST is for machine to machine communication and not for human to machine communication. You can develop a 1st party REST client, which sends the activation to the REST service.

You can use your verification URI in the browser to access the REST client:

# user follows a hyperlink in the browser manually

GET example.com/client/v1/verify/{token}
# asking the client to verify the token

and after that the REST client will get the hyperlink for verification from the REST service and send the POST to the service in the background.

# the REST client follows the hyperlinks given by the service automatically
# the REST client can run either on the HTTP client or server side

GET example.com/api/v1
# getting the starting page of the REST service
# getting the hyperlink for verification

POST example.com/api/v1/verification {token}
# following the verification hyperlink

If you have a server side 1st party REST client, then the HTTP requests to the REST service will run completely on the server and you won't see anything about it in the browser. If you have a client side REST client, then you can send the POST in the browser with AJAX CORS or you can try to POST directly with a HTML form (not recommended). Anyways the activation should be a POST or a PUT.

like image 130
inf3rno Avatar answered Jun 06 '23 15:06

inf3rno


It depends on what are you trying to do.

Does it fire an email after validating the user for example? If so, it is not an idempotent method and you should use POST.

Example:

POST /users/{id}/verify/{token}

If the method doesn't have any consequence besides the update, I think you should use PUT.

like image 22
Bruno Costa Avatar answered Jun 06 '23 16:06

Bruno Costa