mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Store appservice ID on register
This commit is contained in:
parent
703826886c
commit
465605d616
@ -182,6 +182,8 @@ class RegistrationHandler(BaseHandler):
|
|||||||
errcode=Codes.EXCLUSIVE
|
errcode=Codes.EXCLUSIVE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
service_id = service.id if service.is_exclusive_user(user_id) else None
|
||||||
|
|
||||||
yield self.check_user_id_not_appservice_exclusive(
|
yield self.check_user_id_not_appservice_exclusive(
|
||||||
user_id, allowed_appservice=service
|
user_id, allowed_appservice=service
|
||||||
)
|
)
|
||||||
@ -190,7 +192,8 @@ class RegistrationHandler(BaseHandler):
|
|||||||
yield self.store.register(
|
yield self.store.register(
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
token=token,
|
token=token,
|
||||||
password_hash=""
|
password_hash="",
|
||||||
|
appservice_id=service_id,
|
||||||
)
|
)
|
||||||
yield registered_user(self.distributor, user)
|
yield registered_user(self.distributor, user)
|
||||||
defer.returnValue((user_id, token))
|
defer.returnValue((user_id, token))
|
||||||
|
@ -76,7 +76,7 @@ class RegistrationStore(SQLBaseStore):
|
|||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def register(self, user_id, token, password_hash,
|
def register(self, user_id, token, password_hash,
|
||||||
was_guest=False, make_guest=False):
|
was_guest=False, make_guest=False, appservice_id=None):
|
||||||
"""Attempts to register an account.
|
"""Attempts to register an account.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -87,16 +87,32 @@ class RegistrationStore(SQLBaseStore):
|
|||||||
upgraded to a non-guest account.
|
upgraded to a non-guest account.
|
||||||
make_guest (boolean): True if the the new user should be guest,
|
make_guest (boolean): True if the the new user should be guest,
|
||||||
false to add a regular user account.
|
false to add a regular user account.
|
||||||
|
appservice_id (str): The ID of the appservice registering the user.
|
||||||
Raises:
|
Raises:
|
||||||
StoreError if the user_id could not be registered.
|
StoreError if the user_id could not be registered.
|
||||||
"""
|
"""
|
||||||
yield self.runInteraction(
|
yield self.runInteraction(
|
||||||
"register",
|
"register",
|
||||||
self._register, user_id, token, password_hash, was_guest, make_guest
|
self._register,
|
||||||
|
user_id,
|
||||||
|
token,
|
||||||
|
password_hash,
|
||||||
|
was_guest,
|
||||||
|
make_guest,
|
||||||
|
appservice_id
|
||||||
)
|
)
|
||||||
self.is_guest.invalidate((user_id,))
|
self.is_guest.invalidate((user_id,))
|
||||||
|
|
||||||
def _register(self, txn, user_id, token, password_hash, was_guest, make_guest):
|
def _register(
|
||||||
|
self,
|
||||||
|
txn,
|
||||||
|
user_id,
|
||||||
|
token,
|
||||||
|
password_hash,
|
||||||
|
was_guest,
|
||||||
|
make_guest,
|
||||||
|
appservice_id
|
||||||
|
):
|
||||||
now = int(self.clock.time())
|
now = int(self.clock.time())
|
||||||
|
|
||||||
next_id = self._access_tokens_id_gen.get_next()
|
next_id = self._access_tokens_id_gen.get_next()
|
||||||
@ -111,9 +127,21 @@ class RegistrationStore(SQLBaseStore):
|
|||||||
[password_hash, now, 1 if make_guest else 0, user_id])
|
[password_hash, now, 1 if make_guest else 0, user_id])
|
||||||
else:
|
else:
|
||||||
txn.execute("INSERT INTO users "
|
txn.execute("INSERT INTO users "
|
||||||
"(name, password_hash, creation_ts, is_guest) "
|
"("
|
||||||
"VALUES (?,?,?,?)",
|
" name,"
|
||||||
[user_id, password_hash, now, 1 if make_guest else 0])
|
" password_hash,"
|
||||||
|
" creation_ts,"
|
||||||
|
" is_guest,"
|
||||||
|
" appservice_id"
|
||||||
|
") "
|
||||||
|
"VALUES (?,?,?,?,?)",
|
||||||
|
[
|
||||||
|
user_id,
|
||||||
|
password_hash,
|
||||||
|
now,
|
||||||
|
1 if make_guest else 0,
|
||||||
|
appservice_id,
|
||||||
|
])
|
||||||
except self.database_engine.module.IntegrityError:
|
except self.database_engine.module.IntegrityError:
|
||||||
raise StoreError(
|
raise StoreError(
|
||||||
400, "User ID already taken.", errcode=Codes.USER_IN_USE
|
400, "User ID already taken.", errcode=Codes.USER_IN_USE
|
||||||
|
Loading…
Reference in New Issue
Block a user