Following some discussions, here's my rough thoughts on creating an "accounts registration" plugin. The use case is having a flow for users to
1/ register an account
2/ receive a "registration code" via email
2/ validate their email using this "registration code"
3/ reset their password if needed
Register an account
1/ anonymous POST on /accountsmgmt/register/<email>
2/ this creates a record {"id": email, "password": hash, "registration-code": uuid}
3/ an email is sent with a link to /accountsmgmt/register/validate/<registration-code>
4/ GETing /accountsmgmt/register/validate/<registration-code>
returns the ID which is the username (the email)
5/ POSTing to /accountsmgmt/register/validate/<registration-code>
creates a kinto account with the same id and password, and updates the current "register" record to mark it as used (or deletes it)
Resetting a password
1/ anonymous POST on acountsmgmt/resetpassword/<email>
2/ this creates a record {"id": email, "reset-code": uuid}
3/ an email is sent with a link to /accountsmgmt/resetpassword/reset/<reset-code>
4/ GETing /accountsmgmt/resetpassword/<reset-code>
returns the ID which is the username (the email)
5/ POSTing the new password to /accountsmgmt/resetpassword/reset/<reset-code>
updates the kinto account with the same ID, and updates the current "register" record to mark it as used (or deletes it)
Using the email (username) as the ID as the advantage of not having several registration or password reset codes laying around for the same user. The drawback is that we're not benefiting from the "kinto resource" management as we're GET/POST-ing on endpoints that are the registration or password reset codes, and not the IDs.
Not sure if that makes sense? Do you have any feedback, ideas or tips?
question plugin-idea scope:authentication