Skip to content

Conversation

@AlphaHydrae
Copy link
Member

The main added feature is the POST /api/users route. Additionally:

  • The backend now has a generic mechanism to send emails (see
    development guide).
  • In addition to what is required for registration, columns have been
    added to the users table to identify the authentication provider.
    Currently there is only the local provider, but in the future there
    may be Facebook, Twitter, etc.
  • When a new user registers, the email is reserved until the
    registration process has been completed. However, after the expiration
    of the last generated OTP (the lifespan defaults to 2 hours), new
    registration requests will be accepted for the same email, replacing the
    incomplete registration (i.e. user) in the database.
  • JWTs now have authorization scopes (see development guide). This is
    used in the context of user registration: a registration OTP is
    retrieved from the link sent in the registration email. This OTP allows
    a user to obtain a JWT with a special register scope. This JWT will
    allow to mark the user's email as verified (in the next PR).
  • JWTs with infinite validity can now be generated (see POST /api/auth
    documentation).

The following code changes and refactorings have been made:

  • The ECMAScript version in .eslintrc.json has been increased to
    ECMAScript 2018 to support the object spread operator.
  • All mentions of "e-mail" have been replaced by "email".
  • All getExpected* functions (e.g. getExpectedUser) that were in
    server/spec/utils.js have been moved to the respective
    server/spec/expectations/<model>.js file. This makes more sense as
    they are expectation-related.
  • The file server/spec/utils.js has been split into several files in
    the new server/spec/utils directory. This was necessary to avoid a
    circular dependency.
  • Test coverage for the files in server/api/auth and
    server/api/users has been brought to 100% excluding parts that will
    be completed when implementing PATCH /api/users/:id, as those
    features are critical to security.

The following changes have been made to the dependencies:

Stories: TG-1, TG-2

The main added feature is the `POST /api/users` route. Additionally:

* The backend now has a generic mechanism to send emails (see
  development guide).
* In addition to what is required for registration, columns have been
  added to the `users` table to identify the authentication provider.
  Currently there is only the local provider, but in the future there
  may be Facebook, Twitter, etc.
* When a new user registers, the email is reserved until the
  registration process has been completed. However, after the expiration
  of the last generated OTP (the lifespan defaults to 2 hours), new
  registration requests will be accepted for the same email, replacing the
  incomplete registration (i.e. user) in the database.
* JWTs now have authorization scopes (see development guide). This is
  used in the context of user registration: a registration OTP is
  retrieved from the link sent in the registration email. This OTP allows
  a user to obtain a JWT with a special `register` scope. This JWT will
  allow to mark the user's email as verified (in the next PR).
* JWTs with infinite validity can now be generated (see `POST /api/auth`
  documentation).

The following code changes and refactorings have been made:

* The ECMAScript version in `.eslintrc.json` has been increased to
  ECMAScript 2018 to support the object spread operator.
* All mentions of "e-mail" have been replaced by "email".
* All `getExpected*` functions (e.g. `getExpectedUser`) that were in
  `server/spec/utils.js` have been moved to the respective
  `server/spec/expectations/<model>.js` file. This makes more sense as
  they are expectation-related.
* The file `server/spec/utils.js` has been split into several files in
  the new `server/spec/utils` directory. This was necessary to avoid a
  circular dependency.
* Test coverage for the files in `server/api/auth` and
  `server/api/users` has been brought to 100% excluding parts that will
  be completed when implementing `PATCH /api/users/:id`, as those
  features are critical to security.

The following changes have been made to the dependencies:

* https://www.npmjs.com/package/fast-glob replaces `glob` as it has a
  Promise-based API.
* `fs-extra` and `handlebars` are now production dependencies instead of
  development dependencies because they are used to load and parse email
  templates when starting the server.
* https://www.npmjs.com/package/js-yaml has been added to parse the YAML
  front matter of emails (see development guide).
* https://www.npmjs.com/package/query-string and
  https://www.npmjs.com/package/url-join have been added to facilitate
  building URLs (used in this PR to build the registration link).

Stories: TG-1, TG-2
@AlphaHydrae AlphaHydrae requested review from Tazaf and saraheig May 23, 2019 17:34
@coveralls
Copy link

coveralls commented May 23, 2019

Coverage Status

Coverage decreased (-0.6%) to 91.449% when pulling 4ad7b13 on story-2-user-registration into fd59ea8 on sprint-3-engage-in-an-action.

Copy link

@saraheig saraheig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GG

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants