Skip to content
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
7 changes: 5 additions & 2 deletions app/api/routes/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@

from app.config.database import get_db
from app.schemas.users import OTPVerifyRequest, UserCreate, UserResponse
from app.services.user import (get_current_user, register_with_otp,
verify_otp_and_create_user)
from app.services.user import (
get_current_user,
register_with_otp,
verify_otp_and_create_user,
)

router = APIRouter()

Expand Down
40 changes: 21 additions & 19 deletions app/migrations/versions/a4b5fabfdeac_add_otp_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,45 @@
Create Date: 2025-07-24 18:30:31.802426

"""

from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision: str = 'a4b5fabfdeac'
down_revision: Union[str, Sequence[str], None] = 'ccf5dc612027'
revision: str = "a4b5fabfdeac"
down_revision: Union[str, Sequence[str], None] = "ccf5dc612027"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('otps',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('email', sa.String(), nullable=False),
sa.Column('otp_code', sa.String(), nullable=False),
sa.Column('name', sa.String(), nullable=False),
sa.Column('password', sa.String(), nullable=True),
sa.Column('is_active', sa.Integer(), nullable=True),
sa.Column('provider_id', sa.String(), nullable=True),
sa.Column('auth_type', sa.String(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('expires_at', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id')
op.create_table(
"otps",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("email", sa.String(), nullable=False),
sa.Column("otp_code", sa.String(), nullable=False),
sa.Column("name", sa.String(), nullable=False),
sa.Column("password", sa.String(), nullable=True),
sa.Column("is_active", sa.Integer(), nullable=True),
sa.Column("provider_id", sa.String(), nullable=True),
sa.Column("auth_type", sa.String(), nullable=False),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("expires_at", sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(op.f('ix_otps_email'), 'otps', ['email'], unique=False)
op.create_index(op.f('ix_otps_id'), 'otps', ['id'], unique=False)
op.create_index(op.f("ix_otps_email"), "otps", ["email"], unique=False)
op.create_index(op.f("ix_otps_id"), "otps", ["id"], unique=False)
# ### end Alembic commands ###


def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_otps_id'), table_name='otps')
op.drop_index(op.f('ix_otps_email'), table_name='otps')
op.drop_table('otps')
op.drop_index(op.f("ix_otps_id"), table_name="otps")
op.drop_index(op.f("ix_otps_email"), table_name="otps")
op.drop_table("otps")
# ### end Alembic commands ###
8 changes: 6 additions & 2 deletions app/services/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
from app.models.user import AuthType, User
from app.schemas.users import UserCreate
from app.settings import settings
from app.utils.auth import (cleanup_expired_otps, generate_otp, hash_password,
validate_strong_password)
from app.utils.auth import (
cleanup_expired_otps,
generate_otp,
hash_password,
validate_strong_password,
)
from app.utils.email import send_otp_email

security = HTTPBearer()
Expand Down
8 changes: 6 additions & 2 deletions app/utils/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

import requests

from app.utils.exceptions import (AppException, RequestConnectionError,
RequestHTTPError, RequestTimeoutError)
from app.utils.exceptions import (
AppException,
RequestConnectionError,
RequestHTTPError,
RequestTimeoutError,
)


def make_request(
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[tool.isort]
profile = "black"
line_length = 88

[tool.black]
line-length = 88