mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-11-22 22:48:00 +00:00
fix user updating
This commit is contained in:
parent
ea0658e2ea
commit
a6f1738b73
|
@ -192,26 +192,29 @@ class Connection(SqlConnection):
|
||||||
|
|
||||||
def put_user(self, username: str, password: str | None, handle: str | None = None) -> Row:
|
def put_user(self, username: str, password: str | None, handle: str | None = None) -> Row:
|
||||||
if self.get_user(username):
|
if self.get_user(username):
|
||||||
data: dict[str, str | datetime | None] = {
|
data: dict[str, str] = {}
|
||||||
'username': username
|
|
||||||
}
|
|
||||||
|
|
||||||
if password:
|
if password:
|
||||||
data['password'] = password
|
data['hash'] = self.hasher.hash(password)
|
||||||
|
|
||||||
if handle:
|
if handle:
|
||||||
data['handler'] = handle
|
data['handle'] = handle
|
||||||
|
|
||||||
else:
|
stmt = Update("users", data)
|
||||||
if password is None:
|
stmt.set_where("username", username)
|
||||||
raise ValueError('Password cannot be empty')
|
|
||||||
|
|
||||||
data = {
|
with self.query(stmt) as cur:
|
||||||
'username': username,
|
return cur.one()
|
||||||
'hash': self.hasher.hash(password),
|
|
||||||
'handle': handle,
|
if password is None:
|
||||||
'created': datetime.now(tz = timezone.utc)
|
raise ValueError('Password cannot be empty')
|
||||||
}
|
|
||||||
|
data = {
|
||||||
|
'username': username,
|
||||||
|
'hash': self.hasher.hash(password),
|
||||||
|
'handle': handle,
|
||||||
|
'created': datetime.now(tz = timezone.utc)
|
||||||
|
}
|
||||||
|
|
||||||
with self.run('put-user', data) as cur:
|
with self.run('put-user', data) as cur:
|
||||||
return cur.one() # type: ignore
|
return cur.one() # type: ignore
|
||||||
|
|
Loading…
Reference in a new issue