src/controllers/authenticationController.js
/**
   * @description This helps a super administrator to change users role
   * @param  {object} req - The request object
   * @param  {object} res - The response object
   * @returns  {object} The response object
   */
@description This helps a super administrator to change users role
@param  {object} req - The request object
@param  {object} res - The response object
@returns  {object} The response object
@description This helps a super administrator to change users role @param { object } req - The request object @param { object } res - The response object @returns { object } The response object
static async assignRole(req, res) {
    const { email, role } = req.value;
    try {
      const user = await UserRepository.update({ email }, { role });
      if (user[0] === 0) {
        const response = new Response(res, 404, 'User not found');
        return response.sendErrorMessage();
      }
      const newUser = {
        email: user[1][0].email,
        userName: user[1][0].user_name,
        role: user[1][0].role
      };
      const response = new Response(res, 200, 'User role updated successfully', { user: newUser });
      return response.sendSuccessResponse();
    } catch (error) {
      return DbErrorHandler.handleSignupError(res, error);
    }
  }
static async assignRole ( req , res ) { const { email , role } = req . value ; try { const user = await UserRepository . update ( { email } , { role } ) ; if ( user [ 0 ] === 0 ) { const response = new Response ( res , 404 , 'User not found' ) ; return response . sendErrorMessage ( ) ; } const newUser = { email : user [ 1 ] [ 0 ] . email , userName : user [ 1 ] [ 0 ] . user_name , role : user [ 1 ] [ 0 ] . role } ; const response = new Response ( res , 200 , 'User role updated successfully' , { user : newUser } ) ; return response . sendSuccessResponse ( ) ; } catch ( error ) { return DbErrorHandler . handleSignupError ( res , error ) ; } }
@description This helps a super administrator to change users role
 @param  {object} req - The request object
 @param  {object} res - The response object
 @returns  {object} The response object
@description This helps a super administrator to change users role @param { object } req - The request object @param { object } res - The response object @returns { object } The response object