HuiiBuh / angular-example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Angular Example

Backend

Basic todo app with authentication which is not alt all secure and encodes the username and the password to a token ;)

Frontend

Example Angular App which uses the backend to show some todo items

Getting started

Running

  • First run the backend (see backend readme)
  • Afterwards run the frontend (see frontend readme)
  • Visit http://127.0.0.1:4200 for the frontend
  • Visit http://127.0.0.1:8000/docs || http://127.0.0.1:8000/redoc for the openapi docs.

Auth

  • If you want to enable a default user which allows you to user the api without auth, set spoof_user to true in the settings.py. This will still allow you to user other users, but you also have a default user for not authenticated requests.
  • To login a user make a request to the http://127.0.0.1:8000/login endpoint and get the user.
    Returns: { username: string; token: string; id: number; }
  • The received token has to be attached to the request as Authorization header req.headers.set('Authorization', user.token). See auth.interceptor for an example.

About


Languages

Language:TypeScript 63.1%Language:Python 17.0%Language:HTML 10.1%Language:SCSS 7.8%Language:JavaScript 2.0%