Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix #69

Merged
merged 3 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,19 @@ STATIC_BASE_URL=http://localhost:9000/frontendstatic/

# use development for frontend as dev else live ["development", "live"]
DOCKER_TARGET=development

# For Frontend
SITE_NAME="DTM-Drone Tasking Manager"
BASE_URL=http://localhost:${BACKEND_WEB_APP_PORT:-8000}/api
API_URL_V1=http://localhost:${BACKEND_WEB_APP_PORT:-8000}/api

DEBUG=False

#SMTP Configuration
SMTP_TLS=True
SMTP_SSL=False
SMTP_PORT=587
SMTP_HOST=smtp.gmail.com
[email protected]
SMTP_PASSWORD=xxxxxxxxxx
[email protected]
14 changes: 5 additions & 9 deletions src/backend/app/users/user_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from app.users.user_schemas import AuthUser, ProfileUpdate
from databases import Database
from fastapi import HTTPException
from pydantic import EmailStr


pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")

Expand Down Expand Up @@ -77,16 +79,10 @@ async def get_user_by_email(db: Database, email: str):
return result


async def get_user_by_username(db: Database, username: str):
query = "SELECT * FROM users WHERE username = :username LIMIT 1;"
result = await db.fetch_one(query, {"username": username})
return result


async def authenticate(
db: Database, username: str, password: str
db: Database, email: EmailStr, password: str
) -> db_models.DbUser | None:
db_user = await get_user_by_username(db, username)
db_user = await get_user_by_email(db, email)
if not db_user:
return None
if not verify_password(password, db_user["password"]):
Expand All @@ -105,7 +101,7 @@ async def get_or_create_user(
id, name, email_address, profile_img, is_active, is_superuser, date_registered
)
VALUES (
:user_id, :name, :email_address, :profile_img, False, False, now()
:user_id, :name, :email_address, :profile_img, True, False, now()
)
ON CONFLICT (id)
DO UPDATE SET profile_img = :profile_img;
Expand Down
10 changes: 0 additions & 10 deletions src/backend/app/users/user_routes.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from typing import Any
from datetime import timedelta
from fastapi import APIRouter, Response, HTTPException, Depends
from typing import Annotated
from fastapi.security import OAuth2PasswordRequestForm
from app.users.user_schemas import (
Token,
UserPublic,
ProfileUpdate,
AuthUser,
)
Expand Down Expand Up @@ -59,14 +57,6 @@ def update_token(current_user: CurrentUser):
return Token(access_token=access_token, refresh_token=refresh_token)


@router.get("/me", response_model=UserPublic)
def read_user_me(current_user: CurrentUser) -> Any:
"""
Get current user.
"""
return current_user


@router.post("/{user_id}/profile")
async def update_user_profile(
user_id: str,
Expand Down
1 change: 0 additions & 1 deletion src/backend/app/users/user_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class AuthUser(BaseModel):


class UserBase(BaseModel):
username: str
email_address: EmailStr
is_active: bool = True
is_superuser: bool = False
Expand Down
Loading