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

Patch #90

Merged
merged 5 commits into from
Aug 6, 2023
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
12 changes: 8 additions & 4 deletions API/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
actions that are required to be performed only once.
"""

from fastapi import FastAPI
from fastapi import FastAPI, status
from fastapi.exceptions import HTTPException

from pymongo.errors import ServerSelectionTimeoutError

app = FastAPI(title="Connecting Villages API",version="V0.2.0",description="API for Connecting Villages")

Expand All @@ -20,7 +23,8 @@
# inits
try:
dbconnection = DBConnection()
print(f"Connection successful:{dbconnection.get_client()}")
except Exception as e:
print(e)
test_conn = DBConnection.get_client().server_info()

except ServerSelectionTimeoutError as e:
raise HTTPException(status_code=status.HTTP_503_SERVICE_UNAVAILABLE)

4 changes: 2 additions & 2 deletions API/services/auth/utils/Auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


ACCESS_TOKEN_EXPIRE_MINUTES = 30 # 30 minutes
REFRESH_TOKEN_EXPIRE_MINUTES = 60 * 24 * 3 # 3 days
REFRESH_TOKEN_EXPIRE_MINUTES = 60 * 3 # 3 hours


class Auth:
Expand Down Expand Up @@ -139,7 +139,7 @@ def generate_access_tokens_from_refresh_tokens(token: str) -> TokenSchema:
except (jwt.JWTError, ValidationError):
raise LoginFailedException(tokens)
tokens['access_token'] = Auth.create_access_token(token_data.sub)
tokens['refresh_token'] = Auth.create_refresh_token(token_data.sub)
tokens['refresh_token'] = token # Do not generate new `REFRESH_ACCESS_TOKEN`, instead, return the original
tokens['status'] = 'login successful'
tokens['role'] = token_data.sub.split("_")[1]
return tokens
Expand Down
4 changes: 2 additions & 2 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @mayureshagashe2105 @HemanthSai7

# DB Generic Queries
./API/services/db/* @HemanthSai7 @mayureshagashe2105
./API/services/db/utils/* @HemanthSai7
/API/services/db/* @HemanthSai7 @mayureshagashe2105
/API/services/db/utils/* @HemanthSai7

# Auth processes
/API/services/auth/* @mayureshagashe2105
Expand Down
4 changes: 2 additions & 2 deletions tests/login_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# from dotenv import load_dotenv
# load_dotenv()

# BASE_URL = "https://ubaformapi-git-prod-fastapis-build.vercel.app" # for GitHub actions
BASE_URL = "https://ubaformapi-git-prod-fastapis-build.vercel.app" # for GitHub actions
# BASE_URL = "http://127.0.0.1:8000" # for testing locally
BASE_URL = "https://ubaformapi-git-fastapi01000andpydanticv2c-80d502-fastapis-build.vercel.app"
# BASE_URL = "https://ubaformapi-git-fastapi01000andpydanticv2c-80d502-fastapis-build.vercel.app"


def get_access_token(data, return_refresh_token=False):
Expand Down
Loading