Mappers and models.
This commit is contained in:
@@ -7,10 +7,8 @@ class UserService(BaseService):
|
||||
|
||||
async def validate_login(self, username, password):
|
||||
model = await self.get(username=username)
|
||||
print("FOUND USER!", model, flush=True)
|
||||
if not model:
|
||||
return False
|
||||
print("AU", password, model.password.value, flush=True)
|
||||
if not await security.verify(password, model["password"]):
|
||||
return False
|
||||
return True
|
||||
@@ -19,9 +17,14 @@ class UserService(BaseService):
|
||||
if await self.exists(username=username):
|
||||
raise Exception("User already exists.")
|
||||
model = await self.new()
|
||||
model['nick'] = username
|
||||
model.email.value = email
|
||||
model.username.value = username
|
||||
model.password.value = await security.hash(password)
|
||||
if await self.save(model):
|
||||
if model:
|
||||
channel = await self.services.channel.ensure_public_channel(model['uid'])
|
||||
if not channel:
|
||||
raise Exception("Failed to create public channel.")
|
||||
return model
|
||||
raise Exception(f"Failed to create user: {model.errors}.")
|
||||
|
||||
Reference in New Issue
Block a user