Giter VIP home page Giter VIP logo

authentication-app-expressjs's Introduction

Authentication

Given an app.js file and a database file userData.db consisting of a table user.

Write APIs to perform operations on the table user containing the following columns,

User Table

Column Type
username TEXT
name TEXT
password TEXT
gender TEXT
location TEXT

API 1

Path: /register

Method: POST

Request

{
  "username": "adam_richard",
  "name": "Adam Richard",
  "password": "richard_567",
  "gender": "male",
  "location": "Detroit"
}
  • Scenario 1

    • Description:

      If the username already exists

    • Response

      • Status code
        400
        
      • Status text
        User already exists
        
  • Scenario 2

    • Description:

      If the registrant provides a password with less than 5 characters

    • Response

      • Status code
        400
        
      • Status text
        Password is too short
        
  • Scenario 3

    • Description:

      Successful registration of the registrant

    • Response

      • Status code
        200
        
      • Status text
      User created successfully
      

API 2

Path: /login

Method: POST

Request

{
  "username": "adam_richard",
  "password": "richard_567"
}
  • Scenario 1

    • Description:

      If an unregistered user tries to login

    • Response

      • Status code
        400
        
      • Status text
        Invalid user
        
  • Scenario 2

    • Description:

      If the user provides incorrect password

    • Response

      • Status code
        400
        
      • Status text
        Invalid password
        
  • Scenario 3

    • Description:

      Successful login of the user

    • Response

      • Status code
        200
        
      • Status text
        Login success!
        

API 3

Path: /change-password

Method: PUT

Request

{
  "username": "adam_richard",
  "oldPassword": "richard_567",
  "newPassword": "richard@123"
}
  • Scenario 1

    • Description:

      If the user provides incorrect current password

    • Response

      • Status code
        400
        
      • Status text
        Invalid current password
        
  • Scenario 2

    • Description:

      If the user provides new password with less than 5 characters

    • Response

      • Status code
        400
        
      • Status text
        Password is too short
        
  • Scenario 3

    • Description:

      Successful password update

    • Response

      • Status code
        200
        
      • Status text
        Password updated
        

Use npm install to install the packages.

Export the express instance using the default export syntax.

Use Common JS module syntax.

authentication-app-expressjs's People

Contributors

jamisaiteja avatar

Watchers

 avatar

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.