Skip to content

Commit fe0d689

Browse files
authored
Merge pull request #80 from hraftery/master
Restore non-App Store support for Slack
2 parents 278a3cd + 36f7208 commit fe0d689

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/pycookiecheat/chrome.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,22 +123,28 @@ def get_macos_config(browser: BrowserType) -> dict:
123123
raise ValueError(errmsg) from e
124124
cookie_file = "~" / app_support / cookies_suffix
125125

126-
# Slack cookies can be in two places on MacOS depending on whether it was
127-
# installed from the App Store or direct download.
128-
if browser is BrowserType.SLACK and not cookie_file.exists():
129-
# And this location if Slack is installed from App Store
126+
# Cookie location and keyring username in MacOS depends on whether the
127+
# application was installed from the App Store or direct download. To find
128+
# out, we simply assume it's direct download and fall back to App Store if
129+
# it's not there. Currently this distinction is only known for Slack, so
130+
# that is the only case handled here.
131+
isAppStore = False
132+
if browser is BrowserType.SLACK and not cookie_file.expanduser().exists():
133+
isAppStore = True
130134
cookie_file = (
131135
"~/Library/Containers/com.tinyspeck.slackmacgap/Data"
132-
/ app_support
133-
/ cookies_suffix
136+
/ app_support / cookies_suffix
134137
)
135138

136139
browser_name = browser.title()
137140
keyring_service_name = f"{browser_name} Safe Storage"
138141

139-
keyring_username = browser_name
140-
if browser is BrowserType.SLACK:
141-
keyring_username = "Slack App Store Key"
142+
if browser is BrowserType.SLACK and isAppStore:
143+
keyring_username = f"{browser_name} App Store Key"
144+
elif browser is BrowserType.SLACK:
145+
keyring_username = f"{browser_name} Key"
146+
else:
147+
keyring_username = f"{browser_name}"
142148

143149
key_material = keyring.get_password(keyring_service_name, keyring_username)
144150
if key_material is None:

0 commit comments

Comments
 (0)