Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
auth: Include user_id in the params returned at the end of mobile flow.
Mateusz Mandera0abbb871558e
diff --git a/templates/zerver/api/changelog.md b/templates/zerver/api/changelog.mdindex 536340f1357..5df9588c295 100644--- a/templates/zerver/api/changelog.md+++ b/templates/zerver/api/changelog.md@@ -20,6 +20,12 @@ format used by the Zulip server that they are interacting with.## Changes in Zulip 5.0+**Feature level 108**++* In the mobile application authentication flow, the authenticated+ user's `user_id` is now included in the parameters encoded in the+ final `zulip://` redirect URL.+**Feature level 107*** [`POST /register`](/api/register-queue), [`PATCH /settings`](/api/update-settings),[`PATCH /realm/user_settings_defaults`](/api/update-realm-user-settings-defaults):diff --git a/version.py b/version.pyindex 57ec384a5c9..dcef96954fa 100644--- a/version.py+++ b/version.py@@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.4.3"# Changes should be accompanied by documentation explaining what the# new level means in templates/zerver/api/changelog.md, as well as# "**Changes**" entries in the endpoint's documentation in `zulip.yaml`.-API_FEATURE_LEVEL = 107+API_FEATURE_LEVEL = 108# Bump the minor PROVISION_VERSION to indicate that folks should provision# only when going from an old version of the code to a newer version. Bumpdiff --git a/zerver/tests/test_auth_backends.py b/zerver/tests/test_auth_backends.pyindex 107c8c392c1..7370ca9c5f7 100644--- a/zerver/tests/test_auth_backends.py+++ b/zerver/tests/test_auth_backends.py@@ -1200,7 +1200,10 @@ class SocialAuthBase(DesktopFlowTestingLib, ZulipTestCase):def test_social_auth_mobile_success(self) -> None:mobile_flow_otp = "1234abcd" * 8- account_data_dict = self.get_account_data_dict(email=self.email, name="Full Name")+ hamlet = self.example_user("hamlet")+ account_data_dict = self.get_account_data_dict(+ email=hamlet.delivery_email, name="Full Name"+ )self.assert_length(mail.outbox, 0)self.user_profile.date_joined = timezone_now() - datetime.timedelta(seconds=JUST_CREATED_THRESHOLD + 1@@ -1231,7 +1234,9 @@ class SocialAuthBase(DesktopFlowTestingLib, ZulipTestCase):query_params = urllib.parse.parse_qs(parsed_url.query)self.assertEqual(parsed_url.scheme, "zulip")self.assertEqual(query_params["realm"], ["http://zulip.testserver"])- self.assertEqual(query_params["email"], [self.example_email("hamlet")])+ self.assertEqual(query_params["email"], [hamlet.delivery_email])+ self.assertEqual(query_params["user_id"], [str(hamlet.id)])+encrypted_api_key = query_params["otp_encrypted_api_key"][0]hamlet_api_keys = get_all_api_keys(self.example_user("hamlet"))self.assertIn(otp_decrypt_api_key(encrypted_api_key, mobile_flow_otp), hamlet_api_keys)diff --git a/zerver/views/auth.py b/zerver/views/auth.pyindex 6a52e865c28..853237d0458 100644--- a/zerver/views/auth.py+++ b/zerver/views/auth.py@@ -382,6 +382,7 @@ def create_response_for_otp_flow(params = {encrypted_key_field_name: otp_encrypt_api_key(key, otp),"email": user_profile.delivery_email,+ "user_id": user_profile.id,"realm": realm_uri,}# We can't use HttpResponseRedirect, since it only allows HTTP(S) URLs