mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-19 04:04:19 -05:00
Merge pull request #637 from blide/develop
SYN-646 - Register endpoint returns refresh_token
This commit is contained in:
commit
c22a3f37a9
@ -187,7 +187,7 @@ class RegisterRestServlet(RestServlet):
|
|||||||
else:
|
else:
|
||||||
logger.info("bind_email not specified: not binding email")
|
logger.info("bind_email not specified: not binding email")
|
||||||
|
|
||||||
result = self._create_registration_details(user_id, token)
|
result = yield self._create_registration_details(user_id, token)
|
||||||
defer.returnValue((200, result))
|
defer.returnValue((200, result))
|
||||||
|
|
||||||
def on_OPTIONS(self, _):
|
def on_OPTIONS(self, _):
|
||||||
@ -198,7 +198,7 @@ class RegisterRestServlet(RestServlet):
|
|||||||
(user_id, token) = yield self.registration_handler.appservice_register(
|
(user_id, token) = yield self.registration_handler.appservice_register(
|
||||||
username, as_token
|
username, as_token
|
||||||
)
|
)
|
||||||
defer.returnValue(self._create_registration_details(user_id, token))
|
defer.returnValue((yield self._create_registration_details(user_id, token)))
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _do_shared_secret_registration(self, username, password, mac):
|
def _do_shared_secret_registration(self, username, password, mac):
|
||||||
@ -225,14 +225,17 @@ class RegisterRestServlet(RestServlet):
|
|||||||
(user_id, token) = yield self.registration_handler.register(
|
(user_id, token) = yield self.registration_handler.register(
|
||||||
localpart=username, password=password
|
localpart=username, password=password
|
||||||
)
|
)
|
||||||
defer.returnValue(self._create_registration_details(user_id, token))
|
defer.returnValue((yield self._create_registration_details(user_id, token)))
|
||||||
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
def _create_registration_details(self, user_id, token):
|
def _create_registration_details(self, user_id, token):
|
||||||
return {
|
refresh_token = yield self.auth_handler.issue_refresh_token(user_id)
|
||||||
|
defer.returnValue({
|
||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
"access_token": token,
|
"access_token": token,
|
||||||
"home_server": self.hs.hostname,
|
"home_server": self.hs.hostname,
|
||||||
}
|
"refresh_token": refresh_token,
|
||||||
|
})
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def onEmailTokenRequest(self, request):
|
def onEmailTokenRequest(self, request):
|
||||||
|
@ -62,12 +62,15 @@ class RegisterRestServletTestCase(unittest.TestCase):
|
|||||||
self.registration_handler.appservice_register = Mock(
|
self.registration_handler.appservice_register = Mock(
|
||||||
return_value=(user_id, token)
|
return_value=(user_id, token)
|
||||||
)
|
)
|
||||||
result = yield self.servlet.on_POST(self.request)
|
(code, result) = yield self.servlet.on_POST(self.request)
|
||||||
self.assertEquals(result, (200, {
|
self.assertEquals(code, 200)
|
||||||
|
det_data = {
|
||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
"access_token": token,
|
"access_token": token,
|
||||||
"home_server": self.hs.hostname
|
"home_server": self.hs.hostname
|
||||||
}))
|
}
|
||||||
|
self.assertDictContainsSubset(det_data, result)
|
||||||
|
self.assertIn("refresh_token", result)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_POST_appservice_registration_invalid(self):
|
def test_POST_appservice_registration_invalid(self):
|
||||||
@ -112,12 +115,15 @@ class RegisterRestServletTestCase(unittest.TestCase):
|
|||||||
})
|
})
|
||||||
self.registration_handler.register = Mock(return_value=(user_id, token))
|
self.registration_handler.register = Mock(return_value=(user_id, token))
|
||||||
|
|
||||||
result = yield self.servlet.on_POST(self.request)
|
(code, result) = yield self.servlet.on_POST(self.request)
|
||||||
self.assertEquals(result, (200, {
|
self.assertEquals(code, 200)
|
||||||
|
det_data = {
|
||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
"access_token": token,
|
"access_token": token,
|
||||||
"home_server": self.hs.hostname
|
"home_server": self.hs.hostname
|
||||||
}))
|
}
|
||||||
|
self.assertDictContainsSubset(det_data, result)
|
||||||
|
self.assertIn("refresh_token", result)
|
||||||
|
|
||||||
def test_POST_disabled_registration(self):
|
def test_POST_disabled_registration(self):
|
||||||
self.hs.config.enable_registration = False
|
self.hs.config.enable_registration = False
|
||||||
|
Loading…
Reference in New Issue
Block a user