Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #905 from KentShikama/add-password-hash
Browse files Browse the repository at this point in the history
Optionally include password hash in createUser endpoint
  • Loading branch information
erikjohnston authored Jul 4, 2016
2 parents 1238203 + bb06907 commit 3de8168
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions synapse/handlers/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ def _submit_captcha(self, ip_addr, private_key, challenge, response):
defer.returnValue(data)

@defer.inlineCallbacks
def get_or_create_user(self, localpart, displayname, duration_seconds):
def get_or_create_user(self, localpart, displayname, duration_seconds,
password_hash=None):
"""Creates a new user if the user does not exist,
else revokes all previous access tokens and generates a new one.
Expand Down Expand Up @@ -394,7 +395,7 @@ def get_or_create_user(self, localpart, displayname, duration_seconds):
yield self.store.register(
user_id=user_id,
token=token,
password_hash=None,
password_hash=password_hash,
create_profile_with_localpart=user.localpart,
)
else:
Expand Down
5 changes: 4 additions & 1 deletion synapse/rest/client/v1/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,12 +410,15 @@ def _do_create(self, user_json):
raise SynapseError(400, "Failed to parse 'duration_seconds'")
if duration_seconds > self.direct_user_creation_max_duration:
duration_seconds = self.direct_user_creation_max_duration
password_hash = user_json["password_hash"].encode("utf-8") \
if user_json.get("password_hash") else None

handler = self.handlers.registration_handler
user_id, token = yield handler.get_or_create_user(
localpart=localpart,
displayname=displayname,
duration_seconds=duration_seconds
duration_seconds=duration_seconds,
password_hash=password_hash
)

defer.returnValue({
Expand Down

0 comments on commit 3de8168

Please sign in to comment.