File tree Expand file tree Collapse file tree 3 files changed +9
-5
lines changed
Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -22,13 +22,15 @@ async def create_admin(session: AsyncSession):
2222 hashed_password = auth .hash_password (password )
2323 community = DBCommunity (
2424 username = ADMIN_USER ,
25- email = "ADMIN_USER" ,
25+ email = "ADMIN_USER@mail.com " ,
2626 password = hashed_password ,
2727 role = "admin" ,
2828 )
29- session .add (community )
30- await session .commit ()
31- await session .refresh (community )
29+ await create_community (session = session , community = community )
30+
31+ # session.add(community)
32+ # await session.commit()
33+ # await session.refresh(community)
3234 return {"msg" : "Admin successfully created" }
3335
3436
Original file line number Diff line number Diff line change @@ -34,9 +34,10 @@ class Community(BaseModel):
3434 email : str
3535
3636
37- # Extends Community Class with hashed password
37+ # Extends Community Class with hashed password and role
3838class CommunityInDB (Community ):
3939 password : str
40+ role : str
4041
4142
4243class News (BaseModel ):
Original file line number Diff line number Diff line change @@ -17,3 +17,4 @@ class Community(SQLModel, table=True):
1717 default_factory = datetime .now ,
1818 sa_column_kwargs = {"onupdate" : datetime .now },
1919 )
20+ role : str = Field (default = "user" ) # user or admin
You can’t perform that action at this time.
0 commit comments