diff options
author | Erik Johnston <erik@matrix.org> | 2016-06-20 14:13:54 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-06-20 14:13:54 +0100 |
commit | 00c281f6a481671c8c37b17aa4ec7216bc551b27 (patch) | |
tree | 95d3dceb57e2edf136192ad32f7a7ccadbdbbeb1 /synapse/storage/registration.py | |
parent | Update change log (diff) | |
parent | Merge pull request #880 from matrix-org/markjh/registered_user (diff) | |
download | synapse-00c281f6a481671c8c37b17aa4ec7216bc551b27.tar.xz |
Merge branch 'develop' of github.com:matrix-org/synapse into release-v0.16.1
Diffstat (limited to 'synapse/storage/registration.py')
-rw-r--r-- | synapse/storage/registration.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/synapse/storage/registration.py b/synapse/storage/registration.py index bda84a744a..3de9e0f709 100644 --- a/synapse/storage/registration.py +++ b/synapse/storage/registration.py @@ -76,7 +76,8 @@ class RegistrationStore(SQLBaseStore): @defer.inlineCallbacks def register(self, user_id, token, password_hash, - was_guest=False, make_guest=False, appservice_id=None): + was_guest=False, make_guest=False, appservice_id=None, + create_profile_with_localpart=None): """Attempts to register an account. Args: @@ -88,6 +89,8 @@ class RegistrationStore(SQLBaseStore): make_guest (boolean): True if the the new user should be guest, false to add a regular user account. appservice_id (str): The ID of the appservice registering the user. + create_profile_with_localpart (str): Optionally create a profile for + the given localpart. Raises: StoreError if the user_id could not be registered. """ @@ -99,7 +102,8 @@ class RegistrationStore(SQLBaseStore): password_hash, was_guest, make_guest, - appservice_id + appservice_id, + create_profile_with_localpart, ) self.get_user_by_id.invalidate((user_id,)) self.is_guest.invalidate((user_id,)) @@ -112,7 +116,8 @@ class RegistrationStore(SQLBaseStore): password_hash, was_guest, make_guest, - appservice_id + appservice_id, + create_profile_with_localpart, ): now = int(self.clock.time()) @@ -157,6 +162,12 @@ class RegistrationStore(SQLBaseStore): (next_id, user_id, token,) ) + if create_profile_with_localpart: + txn.execute( + "INSERT INTO profiles(user_id) VALUES (?)", + (create_profile_with_localpart,) + ) + @cached() def get_user_by_id(self, user_id): return self._simple_select_one( |