username gen

This commit is contained in:
Untone 2021-07-30 10:18:04 +03:00
parent c2361039ec
commit 8c6e1bcfa6
2 changed files with 2 additions and 1 deletions

View File

@ -10,7 +10,7 @@ class User(Base):
__tablename__ = 'user'
email: str = Column(String, nullable=False)
username: str = Column(String, nullable=True, comment="Name")
username: str = Column(String, nullable=False, comment="Name")
password: str = Column(String, nullable=True, comment="Password")
role_id: list = Column(ForeignKey("role.id"), nullable=True, comment="Role")

View File

@ -16,6 +16,7 @@ async def register(*_, email: str, password: str) -> User:
inp = { "email": email, "password": password}
create_user = CreateUser(**inp)
create_user.password = Password.encode(create_user.password)
create_user.username = email.split('@')[0]
user = User.create(**create_user.dict())
# if not password: # TODO: send confirmation email
token = await Authorize.authorize(user)