What's the REST way to verify an email?

后端 未结 3 1866
情书的邮戳
情书的邮戳 2021-02-18 19:53

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}
         


        
3条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-18 20:49

    Aren't you overthinking REST? With e-mail verification you want the user to be able to simply click the link from whatever mail user agent he is using, so you'll end up with a simple GET on the server (presented as a hyperlink to the user) with the token either in the path or as part of the query string:

    GET http://example.com/verify-email/TOKEN
    GET http://example.com/verify-email?token=TOKEN
    

    Either is fine for this use case. It is not really a resource you are getting or creating; just a trigger for some process on the backend.

    Why do you think this would run afoul of good design?

提交回复
热议问题