Giter VIP home page Giter VIP logo

fastapi-login-sys's Introduction

Basic Login System

This is a basic login system that will create ticket upon successful user login. The backend server is built using FastAPI.

Getting Started

Prerequisite

Python v3.11.6 is used for development.

Installing

Run the following commands to create a virtual environment and install all necessary dependencies:

python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt

Then, run the following command to launch the backend server

uvicorn app:app

You will notice that a ".db" file is created. That is a SQLite database used to store data!
To launch frontend, double click index.html to open it in browser.

User Guide

index.html is the initial landing page for login, and home.html is only accessible upon successful login.
Please open the HTML files directly in browser, after launching the backend server.
The table below shows the existing user credentials for login:

Username Password
John Doe john123
Oyen cuteOyen
All the credentials are case-sensitive

After entering username and password accordingly, click "Login" button to login. Upon successful login, user will be redirected to home.html.
In home.html, user can click "Logout" hyperlink to log out. After logging out, the user cannot access home.html anymore.

Developer Guide

Before launching the backend server, developers should take note the following tips:
  1. To change the ".db" filename, do it at config.py.
  2. If you launch the backend server in different port number (other than 8000), please modify the host and port number at src/functions.js.
  3. If you would like to add more authenticated users, please modify the SQL in the insert_users_sql variable at services/service.py.

All authenticated users are stored in the USERS table. Upon successful login, the backend system will create a ticket and add both username and ticket string to the TICKETS table. The ticket will be saved in session variable too.
When home.html is accessed, the system will retrieve the ticket string in the session variable and check its existence in TICKETS table.
When user logout, the system delete the ticket string from the TICKETS table. The session variable is removed from the frontend side. This will restrict the user to access the home.html or other authenticated webpages.
Frontend and backend are integrated through FastAPI.

fastapi-login-sys's People

Contributors

teojjss 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.