REST验证电子邮件的方式是什么? [英] What's the REST way to verify an email?

查看:78
本文介绍了REST验证电子邮件的方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户注册到我的Web应用程序时,我会发送一封电子邮件以验证其收件箱。
在电子邮件中,有指向以下资源的链接:

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}

由于资源是在后台更新的,这是否破坏了RESTful方法?

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

如何以REST方式进行操作?

How can I do it in a RESTful manner?

推荐答案

您在说什么关于不是REST。 REST用于机器对机器的通信,而不是用于人对机器的通信。您可以开发第一方REST客户端,该客户端将激活发送到REST服务。

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.

您可以在浏览器中使用验证URI来访问REST客户端:

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

之后,REST客户端将从REST服务获取用于验证的超链接,并将POST发送到后台服务。

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

如果您有服务器第一方REST客户端,那么对REST服务的HTTP请求将完全在服务器上运行,并且您在浏览器中将看不到任何有关它的信息。如果您有客户端REST客户端,则可以使用AJAX CORS在浏览器中发送POST,也可以尝试直接使用HTML表单(不推荐)进行POST。无论如何,激活应该是POST或PUT。

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.

这篇关于REST验证电子邮件的方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆