summaryrefslogtreecommitdiff
path: root/Projekt/app/routers/auth.py
diff options
context:
space:
mode:
authorRasmus Luha <rasmus.luha@gmail.com>2022-02-06 13:41:11 +0200
committerRasmus Luha <rasmus.luha@gmail.com>2022-02-06 13:41:11 +0200
commit6a6afdbe72c626b01245c9372c9d10be79789bb0 (patch)
treecfdb5aea7538296bad0105c813fce4cd33c19ef5 /Projekt/app/routers/auth.py
parent5e19a0569288de21365c61b0db78639880732dd0 (diff)
restrucurring the stucture of the folderstruture --> structure
Diffstat (limited to 'Projekt/app/routers/auth.py')
-rw-r--r--Projekt/app/routers/auth.py22
1 files changed, 0 insertions, 22 deletions
diff --git a/Projekt/app/routers/auth.py b/Projekt/app/routers/auth.py
deleted file mode 100644
index 30668cf..0000000
--- a/Projekt/app/routers/auth.py
+++ /dev/null
@@ -1,22 +0,0 @@
-from fastapi import APIRouter, Depends, status, HTTPException, Response
-from fastapi.security.oauth2 import OAuth2PasswordRequestForm
-from sqlalchemy.orm import Session
-from .. import database, schemas, models, utils, oauth2
-
-router = APIRouter(tags = ["Authentication"])
-
-@router.post("/login", response_model = schemas.Token)
-def login(user_credentials: OAuth2PasswordRequestForm = Depends(), db: Session = Depends(database.get_db)): #OAuth2Password... --> nüüd ei oota api requesti bodysse email, password vaid hoopis form-data.
-
- user = db.query(models.User).filter(models.User.email == user_credentials.username).first()
-
- if not user:
- raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="Invalid Credentials unfortunatuun")
-
- if not utils.verify(user_credentials.password, user.password):
- raise HTTPException(status_code=status.HTTP_403_FORBIDDEN , detail="Invalid Credentials unfortunatuun")
-
- #Create and retrn token
- access_token = oauth2.create_access_token(data = {"user_id":user.id})
-
- return {"access_token" : access_token, "token_type" : "bearer" }