mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	settings: Don't mention username in fetch API key error message.
There isn't a username prompt in the form for it, so the only possibility for triggering this error is a wrong password. Fixes #20924.
This commit is contained in:
		@@ -4345,7 +4345,7 @@ class JSONFetchAPIKeyTest(ZulipTestCase):
 | 
			
		||||
        user = self.example_user("hamlet")
 | 
			
		||||
        self.login_user(user)
 | 
			
		||||
        result = self.client_post("/json/fetch_api_key", dict(password="wrong"))
 | 
			
		||||
        self.assert_json_error(result, "Your username or password is incorrect.", 400)
 | 
			
		||||
        self.assert_json_error(result, "Password is incorrect.", 400)
 | 
			
		||||
 | 
			
		||||
    def test_invalid_subdomain(self) -> None:
 | 
			
		||||
        username = "hamlet"
 | 
			
		||||
 
 | 
			
		||||
@@ -1143,7 +1143,7 @@ class FetchAPIKeyTest(ZulipTestCase):
 | 
			
		||||
    def test_fetch_api_key_wrong_password(self) -> None:
 | 
			
		||||
        self.login("cordelia")
 | 
			
		||||
        result = self.client_post("/json/fetch_api_key", dict(password="wrong_password"))
 | 
			
		||||
        self.assert_json_error_contains(result, "password is incorrect")
 | 
			
		||||
        self.assert_json_error_contains(result, "Password is incorrect")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class InactiveUserTest(ZulipTestCase):
 | 
			
		||||
 
 | 
			
		||||
@@ -977,7 +977,7 @@ def json_fetch_api_key(
 | 
			
		||||
        if not authenticate(
 | 
			
		||||
            request=request, username=user_profile.delivery_email, password=password, realm=realm
 | 
			
		||||
        ):
 | 
			
		||||
            raise JsonableError(_("Your username or password is incorrect."))
 | 
			
		||||
            raise JsonableError(_("Password is incorrect."))
 | 
			
		||||
 | 
			
		||||
    api_key = get_api_key(user_profile)
 | 
			
		||||
    return json_success({"api_key": api_key, "email": user_profile.delivery_email})
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user