generated _collections class
This commit is contained in:
parent
842c127817
commit
938f950646
6 changed files with 132 additions and 13 deletions
|
|
@ -10,6 +10,7 @@ from fastapi.security import OAuth2PasswordBearer
|
|||
from pydantic.networks import EmailStr
|
||||
from sqlalchemy import Column, Integer, String
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlalchemy.dialects.postgresql import ARRAY
|
||||
from email.message import EmailMessage
|
||||
import jwt
|
||||
|
||||
|
|
@ -53,6 +54,7 @@ class UserCreate(BaseModel):
|
|||
status: Status | None = None
|
||||
password : str | None = None
|
||||
|
||||
|
||||
### VERİTABANI MODELİ ###
|
||||
class DBUser(Base):
|
||||
__tablename__ = "users_table"
|
||||
|
|
@ -64,6 +66,9 @@ class DBUser(Base):
|
|||
role = Column(String, default="user")
|
||||
status = Column(String, default="active")
|
||||
created_date = Column(String, default=datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S"))
|
||||
bio = Column(String, default="No bio")
|
||||
collections = Column(ARRAY(String), default=['likes'])
|
||||
follower_user = Column(ARRAY(Integer), default=[])
|
||||
|
||||
|
||||
### AUTH ###
|
||||
|
|
@ -230,11 +235,9 @@ def update_password_w_user(
|
|||
user: Annotated[DBUser , None],
|
||||
password: str | None = None,
|
||||
|
||||
):
|
||||
) -> any:
|
||||
|
||||
hashed_password = get_password_hash(password)
|
||||
session.query(DBUser).filter(DBUser.user_id == user.user_id).update({"hashed_password": hashed_password})
|
||||
session.commit()
|
||||
session.refresh(user)
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue