Skip to content

Commit

Permalink
add email to user registration
Browse files Browse the repository at this point in the history
  • Loading branch information
sepehrsh79 committed Oct 1, 2024
1 parent 9db4730 commit 90052e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/controllers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(
self.db_session = db_session
self.redis_session = redis_session

async def register(self, password: str, username: str) -> UserOutRegister:
async def register(self, password: str, username: str, email: str) -> UserOutRegister:
user = await self.user_crud.get_by_username(
self.db_session,
username=username,
Expand All @@ -50,6 +50,7 @@ async def register(self, password: str, username: str) -> UserOutRegister:
db_session=self.db_session,
username=username,
password=password,
email=email,
gauth=str(random_base32()),
)

Expand All @@ -62,6 +63,7 @@ async def register(self, password: str, username: str) -> UserOutRegister:
updated_at=user.updated_at,
created_at=user.created_at,
gauth=user.gauth,
email=user.email,
qr_img=base64.b64encode(buffered.getvalue()).decode(),
)

Expand Down Expand Up @@ -108,6 +110,7 @@ async def me(self, user_id) -> UserOut:
return UserOut(
id=user.id,
username=user.username,
email=user.email,
updated_at=user.updated_at,
created_at=user.created_at,
)
Expand Down
6 changes: 3 additions & 3 deletions src/routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
get_current_user_from_db,
get_current_user_with_refresh,
)
from src.schema.user import UserIn, UserOut, UserOutRegister
from src.schema.user import UserRegister, UserOut, UserOutRegister, UserLogin

router = APIRouter(
prefix="/auth",
Expand All @@ -21,14 +21,14 @@
"/register", description="register new user", response_model=UserOutRegister
)
async def register(
data: UserIn, db_session: DBManager = Depends(get_db)
data: UserRegister, db_session: DBManager = Depends(get_db)
) -> UserOutRegister:
return await AuthController(db_session=db_session).register(**data.dict())


@router.post("/login", description="Create access and refresh tokens for verified user")
async def login(
data: UserIn,
data: UserLogin,
request: Request,
response: Response,
db_session: DBManager = Depends(get_db),
Expand Down

0 comments on commit 90052e7

Please sign in to comment.