mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-12-10 21:42:43 -05:00
Merge branch 'develop' into refresh
Conflicts: synapse/rest/client/v1/login.py
This commit is contained in:
commit
e8cf77fa49
19 changed files with 498 additions and 80 deletions
|
|
@ -74,13 +74,20 @@ class LoginRestServlet(ClientV1RestServlet):
|
|||
|
||||
@defer.inlineCallbacks
|
||||
def do_password_login(self, login_submission):
|
||||
if not login_submission["user"].startswith('@'):
|
||||
login_submission["user"] = UserID.create(
|
||||
login_submission["user"], self.hs.hostname).to_string()
|
||||
if 'medium' in login_submission and 'address' in login_submission:
|
||||
user_id = yield self.hs.get_datastore().get_user_id_by_threepid(
|
||||
login_submission['medium'], login_submission['address']
|
||||
)
|
||||
else:
|
||||
user_id = login_submission['user']
|
||||
|
||||
if not user_id.startswith('@'):
|
||||
user_id = UserID.create(
|
||||
user_id, self.hs.hostname).to_string()
|
||||
|
||||
auth_handler = self.handlers.auth_handler
|
||||
access_token, refresh_token = yield auth_handler.login_with_password(
|
||||
user_id=login_submission["user"],
|
||||
user_id=user_id,
|
||||
password=login_submission["password"])
|
||||
|
||||
result = {
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class PasswordRestServlet(RestServlet):
|
|||
new_password = params['new_password']
|
||||
|
||||
yield self.auth_handler.set_password(
|
||||
user_id, new_password, None
|
||||
user_id, new_password
|
||||
)
|
||||
|
||||
defer.returnValue((200, {}))
|
||||
|
|
|
|||
|
|
@ -54,6 +54,11 @@ class RegisterRestServlet(RestServlet):
|
|||
@defer.inlineCallbacks
|
||||
def on_POST(self, request):
|
||||
yield run_on_reactor()
|
||||
|
||||
if '/register/email/requestToken' in request.path:
|
||||
ret = yield self.onEmailTokenRequest(request)
|
||||
defer.returnValue(ret)
|
||||
|
||||
body = parse_json_dict_from_request(request)
|
||||
|
||||
# we do basic sanity checks here because the auth layer will store these
|
||||
|
|
@ -208,6 +213,29 @@ class RegisterRestServlet(RestServlet):
|
|||
"home_server": self.hs.hostname,
|
||||
}
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def onEmailTokenRequest(self, request):
|
||||
body = parse_json_dict_from_request(request)
|
||||
|
||||
required = ['id_server', 'client_secret', 'email', 'send_attempt']
|
||||
absent = []
|
||||
for k in required:
|
||||
if k not in body:
|
||||
absent.append(k)
|
||||
|
||||
if len(absent) > 0:
|
||||
raise SynapseError(400, "Missing params: %r" % absent, Codes.MISSING_PARAM)
|
||||
|
||||
existingUid = yield self.hs.get_datastore().get_user_id_by_threepid(
|
||||
'email', body['email']
|
||||
)
|
||||
|
||||
if existingUid is not None:
|
||||
raise SynapseError(400, "Email is already in use", Codes.THREEPID_IN_USE)
|
||||
|
||||
ret = yield self.identity_handler.requestEmailToken(**body)
|
||||
defer.returnValue((200, ret))
|
||||
|
||||
|
||||
def register_servlets(hs, http_server):
|
||||
RegisterRestServlet(hs).register(http_server)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue