feat: api endpoint to receive profile_image_uirl on signup

This commit is contained in:
Danny Liu 2024-04-03 22:36:27 -07:00
parent 6bb299ae25
commit 8d1db9a1c0
3 changed files with 7 additions and 6 deletions

View file

@ -82,6 +82,7 @@ class SignupForm(BaseModel):
name: str
email: str
password: str
profile_image_url: str
class AuthsTable:
@ -90,7 +91,7 @@ class AuthsTable:
self.db.create_tables([Auth])
def insert_new_auth(
self, email: str, password: str, name: str, role: str = "pending"
self, email: str, password: str, name: str, profile_image_url: str, role: str = "pending"
) -> Optional[UserModel]:
log.info("insert_new_auth")
@ -101,7 +102,7 @@ class AuthsTable:
)
result = Auth.create(**auth.model_dump())
user = Users.insert_new_user(id, name, email, role)
user = Users.insert_new_user(id, name, email, profile_image_url, role)
if result and user:
return user

View file

@ -30,7 +30,7 @@ class UserModel(BaseModel):
name: str
email: str
role: str = "pending"
profile_image_url: str = "/user.png"
profile_image_url: str
timestamp: int # timestamp in epoch
@ -57,7 +57,7 @@ class UsersTable:
self.db.create_tables([User])
def insert_new_user(
self, id: str, name: str, email: str, role: str = "pending"
self, id: str, name: str, email: str, profile_image_url: str, role: str = "pending",
) -> Optional[UserModel]:
user = UserModel(
**{
@ -65,7 +65,7 @@ class UsersTable:
"name": name,
"email": email,
"role": role,
"profile_image_url": "/user.png",
"profile_image_url": profile_image_url,
"timestamp": int(time.time()),
}
)

View file

@ -146,7 +146,7 @@ async def signup(request: Request, form_data: SignupForm):
)
hashed = get_password_hash(form_data.password)
user = Auths.insert_new_auth(
form_data.email.lower(), hashed, form_data.name, role
form_data.email.lower(), hashed, form_data.name, form_data.profile_image_url, role
)
if user: