Create User

Normal flow

  • A client sends a name, e-mail and password.
  • The service receives and validates the data. The name must be not empty, the e-mail must be unique in the server and the format must be valid and, the password must be bigger than eight characters.
  • The service encrypts the password and generates an identifier (hash) of the new user.
  • The service creates the new user in the data repository and sends an e-mail to the user with the validation code.
  • The service returns some user’s data.

Sequence diagram of the normal flow

Sequence

HTTPS endpoints

  • /users/create
  • Method: POST
  • Consumes: application/x-www-form-urlencoded
  • Produces: application/json
  • Examples:

    • Example of request:
  curl -X 'POST' \
  'http://localhost:8080/users/create' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'name=Orion&email=orion%40services.dev&password=12345678'
  • Example of response: User in JSON.
{
  "hash": "08f9c3ca-e22e-457f-822a-2d8efafbc720",
  "name": "Orion",
  "email": "orion@oservices.dev",
  "emailValid": false,
  "secret2FA": null,
  "using2FA": false
}

Exceptions

In the use case layer, exceptions related with arguments will be IllegalArgumentException. However, in the RESTful Web Service layer will be transformed to Bad Request (HTTP 400).


Copyright © 2024 Orion Services. Distributed by Apache 2.0 license.