|
99 | 99 | APP_PACKAGE).expanduser() # Windows startup .cmd file location |
100 | 100 | AUTOSTART_FILE_PATH = pathlib.Path('~/.config/autostart/%s.desktop' % APP_PACKAGE).expanduser() # XDG Autostart file |
101 | 101 |
|
102 | | -EXTERNAL_AUTH_HTML = '''<html><style type="text/css">body{margin:20px auto;line-height:1.3;font-family:sans-serif; |
103 | | - font-size:16px;color:#444;padding:0 24px}</style> |
| 102 | +EXTERNAL_AUTH_HTML = '''<html><head><script type="text/javascript">function copyLink(targetLink){ |
| 103 | + var copySource=document.createElement('textarea');copySource.value=targetLink;copySource.style.position='absolute'; |
| 104 | + copySource.style.left='-9999px';document.body.appendChild(copySource);copySource.select(); |
| 105 | + document.execCommand('copy');document.body.removeChild(copySource); |
| 106 | + document.getElementById('copy').innerText='✔'}</script><style type="text/css">body{margin:20px auto;line-height:1.3; |
| 107 | + font-family:sans-serif;font-size:16px;color:#444;padding:0 24px}</style></head><body> |
104 | 108 | <h3 style="margin:0.3em 0;">Login authorisation request for %s</h3> |
105 | 109 | <p style="margin-top:0">Click the following link to open your browser and approve the request:</p> |
106 | | - <p><a href="%s" target="_blank" style="word-wrap:break-word;word-break:break-all">%s</a></p> |
| 110 | + <p><a href="%s" target="_blank" style="word-wrap:break-word;word-break:break-all">%s</a> |
| 111 | + <a id="copy" onclick="copyLink('%s')" style="margin-left:0.5em;margin-top:0.1em;font-weight:bold;font-size:150%%; |
| 112 | + text-decoration:none;cursor:pointer;float:right" title="Copy link">⧉</a></p> |
107 | 113 | <p style="margin-top:2em">After logging in and successfully authorising your account, paste and submit the |
108 | | - resulting URL from the browser's address bar using the box below to allow the %s script to transparently |
109 | | - handle login requests on your behalf in future.</p> |
| 114 | + resulting URL from the browser's address bar using the box at the bottom of this page to allow the %s script to |
| 115 | + transparently handle login requests on your behalf in future.</p> |
110 | 116 | <p>Note that your browser may show a navigation error (e.g., <em>"localhost refused to connect"</em>) after |
111 | 117 | successfully logging in, but the final URL is the only important part, and as long as this begins with the |
112 | 118 | correct redirection URI and contains a valid authorisation code your email client's request will succeed.''' + ( |
|
117 | 123 | document.auth.submit.value='Submitting...'; document.auth.submit.disabled=true; return false"> |
118 | 124 | <div style="display:flex;flex-direction:row;margin-top:4em"><label for="url">Authorisation success URL: |
119 | 125 | </label><input type="text" name="url" id="url" style="flex:1;margin:0 5px;width:65%%"><input type="submit" |
120 | | - id="submit" value="Submit"></div></form></html>''' |
| 126 | + id="submit" value="Submit"></div></form></body></html>''' |
121 | 127 |
|
122 | 128 | EXITING = False # used to check whether to restart failed threads - is set to True if the user has requested to exit |
123 | 129 |
|
@@ -1712,7 +1718,7 @@ def create_authorisation_window(self, request): |
1712 | 1718 | window_title = 'Authorise your account: %s' % request['username'] |
1713 | 1719 | if self.args.external_auth: |
1714 | 1720 | auth_page = EXTERNAL_AUTH_HTML % (request['username'], request['permission_url'], request['permission_url'], |
1715 | | - APP_NAME, request['redirect_uri']) |
| 1721 | + request['permission_url'], APP_NAME, request['redirect_uri']) |
1716 | 1722 | authorisation_window = webview.create_window(window_title, html=auth_page, on_top=True, text_select=True) |
1717 | 1723 | else: |
1718 | 1724 | authorisation_window = webview.create_window(window_title, request['permission_url'], on_top=True) |
|
0 commit comments