controllers/userController.js
/**
   * Handles user sign up.
   *
   * User credentials are retrieved from the request body and creates new user
   * model. Password is hashed and json-web-token is generated. Auth token is
   * set in cookie on response.
   *
   * @param {fastify.Request} req Fastify request instance.
   * @param {fastify.Reply} rep Fastify reply instance.
   */
Handles user sign up.
User credentials are retrieved from the request body and creates new user
model. Password is hashed and json-web-token is generated. Auth token is
set in cookie on response.

@param {fastify.Request} req Fastify request instance.
@param {fastify.Reply} rep Fastify reply instance.
Handles user sign up . User credentials are retrieved from the request body and creates new user model . Password is hashed and json - web - token is generated . Auth token is set in cookie on response . @param { fastify . Request } req Fastify request instance . @param { fastify . Reply } rep Fastify reply instance .
static async handleUserSignUp(req, rep) {
    const firstName = req.body.firstName;
    const lastName = req.body.lastName;
    const email = req.body.email;
    const password = req.body.password;
    const passwordHash = await bcrypt.hash(password, 12);
    const user = await this.models.user.create({
      firstName: firstName,
      lastName: lastName,
      email: email,
      password: passwordHash,
      administrator: false
    });
    const token = await rep.jwtSign({
      id: user.id,
      email: user.email
    });
    const serializedUser = UserSerializer.serialize(user);
    await rep.setCookie('token', token, {
      path: '/',
      httpOnly: true,
      sameSite: true
    }).code(200).send(serializedUser);
  }
static async handleUserSignUp ( req , rep ) { const firstName = req . body . firstName ; const lastName = req . body . lastName ; const email = req . body . email ; const password = req . body . password ; const passwordHash = await bcrypt . hash ( password , 12 ) ; const user = await this . models . user . create ( { firstName : firstName , lastName : lastName , email : email , password : passwordHash , administrator : false } ) ; const token = await rep . jwtSign ( { id : user . id , email : user . email } ) ; const serializedUser = UserSerializer . serialize ( user ) ; await rep . setCookie ( 'token' , token , { path : '/' , httpOnly : true , sameSite : true } ) . code ( 200 ) . send ( serializedUser ) ; }
Handles user sign up.
Handles user sign up .