Giter Club home page Giter Club logo

bashaway-backend's People

Contributors

akalanka47000 avatar danuja01 avatar fazidsamoon avatar fullstacksorcerer avatar gihaa avatar laksara-007 avatar nilupulmadhawa avatar nisalrenuja avatar qbicsquid avatar quintusjoyal avatar radser2001 avatar saputhebeast avatar sasindunanayakkara avatar sayumimunasinghe avatar shabinaf avatar shafdo avatar sithumonline avatar thulinawickramasinghe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bashaway-backend's Issues

Add workflow to run code quality checks on pull requests to development and main branches

There'll be 3 jobs to be run in parallel

  • Run linter
  • Run prettier formatter and if there are changes left on complete, add them back and commit to the repo if there is enough permission or else fail the job with a suitable error message
  • Run commitlint and validate the commit message

All 3 can implemented as reusable actions under the following repo and consumed. Later these can be united under a resuable workflow. A new folder with a name of code-quality can be added for this purpose and registered under workspaces

The third needs to check if the repo already has a commitlint.config.js file and if it is not there, download one which is defined under the actions directory, the contents of the file will be the same as the ones in this repo. The necessary dependencies must be installed as well if not already available

Error response messages

Responses for bad requests that prompt bad database queries (such as requests with invalid object ID's) are sent with status 500 (Internal server error).

The messages must be fixed so that the cause of the error is clear. @Akalanka47000

Inefficient user scoring

When all user scores must be updates, the scoring API must be called for each user. Which is tedious on the front end and inefficient on the back end (because the question list must be retrieved over and over, for each user).

[BUG๐Ÿž] Business Logic Flaw in the verification email process

Summary

  • I have already registered and logged in. Even though I can resend verification emails.

POC

  1. Register a new user and log in to the Bashaway server as usual.
  2. You can visit this endpoint (POST) /api/auth/verify and send a verification email again. Have a look at the example request bellow:
POST /api/auth/verify HTTP/1.1
Host: localhost:3001
Content-Type: application/json
Content-Length: 43

{
    "email": "[email protected]"
}

Postman Preview:

image

Impact

  • It is possible for someone to send emails recursively. So our email quota gets over.

[BUG๐Ÿž] Business Logic Flaw in the registration for logged in user

Summary

  • I have already logged in as a user. Even though I can register another user account while I'm already been logged in.

POC

  1. Log in as an existing user.
  2. Verify your login by visiting (GET) /api/auth/current.
  3. Now try registering a new user. By going to the following endpoint (POST) /api/auth/register. Have a look at the example request bellow:
POST /api/auth/register HTTP/1.1
Host: localhost:3000
Authorization: Bearer <YOUR-JWT-TOKEN>
Content-Type: application/json
Content-Length: 715

{
  "name": "Brand New User",
  "email": "[email protected]",
  "password": "Pass0000#",
  "university": "SLIIT",
  "members": [
    {
      "name": "DanTheMan",
      "email": "[email protected]",
      "phone": "0725661324",
      "academic_year": 4
    },
  ]
}

Postman Preview:

  • Login to bashaway backend

image

  • Verify I'm logged in

image

  • Registering a new user even though I'm logged in

image

Impact

  • Generally if a user is already logged in. That particular user cannot be able to register a new account. Unless logging out from the platform.

Internal server error response for body-parser errors

When sending a request with a json body that has syntactic errors, The server responds with status code 500 (Internal server error), Although the issue lies with the request.

@Akalanka47000

Sample request with an invalid json body:

curl -v -X POST -d '{,}' --header "Content-Type: application/json" http://localhost:3001/api/auth/register

Response:

< HTTP/1.1 500 Internal Server Error

Response body:

{
  "message": "Just patching things up. This'll be over in a jiffy!"
}

Log:

{"level":"error","message":"Error: Unexpected token , in JSON at position 1 | Stack: SyntaxError: Unexpected token , in JSON at position 1
    at JSON.parse (<anonymous>)
    at parse (/home/shifan/projects/bashaway-backend/node_modules/body-parser/lib/types/json.js:89:19)
    at /home/shifan/projects/bashaway-backend/node_modules/body-parser/lib/read.js:128:18
    at AsyncResource.runInAsyncScope (node:async_hooks:203:9)
    at invokeCallback (/home/shifan/projects/bashaway-backend/node_modules/raw-body/index.js:231:16)
    at done (/home/shifan/projects/bashaway-backend/node_modules/raw-body/index.js:220:7)
    at IncomingMessage.onEnd (/home/shifan/projects/bashaway-backend/node_modules/raw-body/index.js:280:7)
    at IncomingMessage.emit (node:events:513:28)
    at IncomingMessage.emit (node:domain:482:12)
    at endReadableNT (node:internal/streams/readable:1359:12)","timestamp":"2022-07-26T11:33:40.968Z"}

Implement settings module

The task is to add the necessary crud operations to add a collection named settings to the db. The collection will have documents each of which holds a different type of setting. As of now there will be 2 types:

  • Submission settings with a key named submission deadline which is a timestamp
  • Registration settings with a key named registration deadline which is a timestamp

The endpoints for this module will only be accessible by admins

Add an attriute named `strict_inputs` to the question model

Indicates that during the evaluation of submissions, the inputs to the problem if provided any will be replaced by their originals within the submission to bypass tampering

  • This is a boolean and defaults to false.
  • It should be added to validators and be optional

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.