Mercurial > libervia-backend
annotate libervia/backend/stdui/ui_profile_manager.py @ 4259:49019947cc76
component AP Gateway: implement HTTP GET signature.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 05 Jun 2024 22:34:09 +0200 |
parents | 4b842c1fb686 |
children |
rev | line source |
---|---|
3028 | 1 #!/usr/bin/env python3 |
3137 | 2 |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
3 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
4 # SAT standard user interface for managing contacts |
3479 | 5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org) |
1766 | 6 # Copyright (C) 2013-2016 Adrien Cossa (souliane@mailoo.org) |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
7 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
8 # This program is free software: you can redistribute it and/or modify |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
9 # it under the terms of the GNU Affero General Public License as published by |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
10 # the Free Software Foundation, either version 3 of the License, or |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
11 # (at your option) any later version. |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
12 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
13 # This program is distributed in the hope that it will be useful, |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
16 # GNU Affero General Public License for more details. |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
17 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
18 # You should have received a copy of the GNU Affero General Public License |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
19 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
20 |
4071
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
21 from libervia.backend.core.i18n import D_ |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
22 from libervia.backend.core.constants import Const as C |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
23 from libervia.backend.core.log import getLogger |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
24 from libervia.backend.core import exceptions |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
25 from libervia.backend.tools import xml_tools |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
26 from libervia.backend.memory.memory import ProfileSessions |
3120 | 27 from twisted.internet import defer |
1089
8e0072754413
core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents:
1088
diff
changeset
|
28 from twisted.words.protocols.jabber import jid |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
29 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
30 |
3120 | 31 log = getLogger(__name__) |
32 | |
33 | |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
34 class ProfileManager(object): |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
35 """Manage profiles.""" |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
36 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
37 def __init__(self, host): |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
38 self.host = host |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
39 self.profile_ciphers = {} |
1043
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
40 self._sessions = ProfileSessions() |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
41 host.register_callback( |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
42 self._authenticate_profile, force_id=C.AUTHENTICATE_PROFILE_ID, with_data=True |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
43 ) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
44 host.register_callback( |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
45 self._change_xmpp_password, force_id=C.CHANGE_XMPP_PASSWD_ID, with_data=True |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
46 ) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
47 self.__new_xmpp_passwd_id = host.register_callback( |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
48 self._change_xmpp_password_cb, with_data=True |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
49 ) |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
50 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
51 def _start_session_eb(self, fail, first, profile): |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
52 """Errback method for start_session during profile authentication |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
53 |
1697
52af44e745b5
core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents:
1608
diff
changeset
|
54 @param first(bool): if True, this is the first try and we have tryied empty password |
52af44e745b5
core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents:
1608
diff
changeset
|
55 in this case we ask for a password to the user. |
52af44e745b5
core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents:
1608
diff
changeset
|
56 @param profile(unicode, None): %(doc_profile)s |
52af44e745b5
core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents:
1608
diff
changeset
|
57 must only be used if first is True |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
58 """ |
1697
52af44e745b5
core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents:
1608
diff
changeset
|
59 if first: |
52af44e745b5
core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents:
1608
diff
changeset
|
60 # first call, we ask for the password |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
61 form_ui = xml_tools.XMLUI( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
62 "form", title=D_("Profile password for {}").format(profile), submit_id="" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
63 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
64 form_ui.addPassword("profile_password", value="") |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
65 d = xml_tools.deferred_ui(self.host, form_ui, chained=True) |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
66 d.addCallback(self._authenticate_profile, profile) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
67 return {"xmlui": form_ui.toXml()} |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
68 |
1697
52af44e745b5
core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents:
1608
diff
changeset
|
69 assert profile is None |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
70 |
1697
52af44e745b5
core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents:
1608
diff
changeset
|
71 if fail.check(exceptions.PasswordError): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
72 dialog = xml_tools.XMLUI("popup", title=D_("Connection error")) |
1697
52af44e745b5
core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents:
1608
diff
changeset
|
73 dialog.addText(D_("The provided profile password doesn't match.")) |
52af44e745b5
core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents:
1608
diff
changeset
|
74 else: |
3028 | 75 log.error("Unexpected exceptions: {}".format(fail)) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
76 dialog = xml_tools.XMLUI("popup", title=D_("Internal error")) |
3028 | 77 dialog.addText(D_("Internal error: {}".format(fail))) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
78 return {"xmlui": dialog.toXml(), "validated": C.BOOL_FALSE} |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
79 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
80 def _authenticate_profile(self, data, profile): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
81 if C.bool(data.get("cancelled", "false")): |
2090
52bd463e6fe7
core(stdui/profile manager): fixed authentication cancellation
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
82 return {} |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
83 if self.host.memory.is_session_started(profile): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
84 return {"validated": C.BOOL_TRUE} |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
85 try: |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
86 password = data[xml_tools.form_escape("profile_password")] |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
87 except KeyError: |
1697
52af44e745b5
core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents:
1608
diff
changeset
|
88 # first request, we try empty password |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
89 password = "" |
1697
52af44e745b5
core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents:
1608
diff
changeset
|
90 first = True |
52af44e745b5
core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents:
1608
diff
changeset
|
91 eb_profile = profile |
52af44e745b5
core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents:
1608
diff
changeset
|
92 else: |
52af44e745b5
core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents:
1608
diff
changeset
|
93 first = False |
52af44e745b5
core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents:
1608
diff
changeset
|
94 eb_profile = None |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
95 d = self.host.memory.start_session(password, profile) |
2765
378188abe941
misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents:
2624
diff
changeset
|
96 d.addCallback(lambda __: {"validated": C.BOOL_TRUE}) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
97 d.addErrback(self._start_session_eb, first, eb_profile) |
1697
52af44e745b5
core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents:
1608
diff
changeset
|
98 return d |
1043
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
99 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
100 def _change_xmpp_password(self, data, profile): |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
101 session_data = self._sessions.profile_get_unique(profile) |
1043
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
102 if not session_data: |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
103 server = self.host.memory.param_get_a( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
104 C.FORCE_SERVER_PARAM, "Connection", profile_key=profile |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
105 ) |
1089
8e0072754413
core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents:
1088
diff
changeset
|
106 if not server: |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
107 server = jid.parse( |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
108 self.host.memory.param_get_a( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
109 "JabberID", "Connection", profile_key=profile |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
110 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
111 )[1] |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
112 session_id, session_data = self._sessions.new_session( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
113 {"count": 0, "server": server}, profile=profile |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
114 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
115 if ( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
116 session_data["count"] > 2 |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
117 ): # 3 attempts with a new password after the initial try |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
118 self._sessions.profile_del_unique(profile) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
119 _dialog = xml_tools.XMLUI("popup", title=D_("Connection error")) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
120 _dialog.addText( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
121 D_("Can't connect to %s. Please check your connection details.") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
122 % session_data["server"] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
123 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
124 return {"xmlui": _dialog.toXml()} |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
125 session_data["count"] += 1 |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
126 counter = " (%d)" % session_data["count"] if session_data["count"] > 1 else "" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
127 title = D_("XMPP password for %(profile)s%(counter)s") % { |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
128 "profile": profile, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
129 "counter": counter, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
130 } |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
131 form_ui = xml_tools.XMLUI( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
132 "form", title=title, submit_id=self.__new_xmpp_passwd_id |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
133 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
134 form_ui.addText( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
135 D_( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
136 "Can't connect to %s. Please check your connection details or try with another password." |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
137 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
138 % session_data["server"] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
139 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
140 form_ui.addPassword("xmpp_password", value="") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
141 return {"xmlui": form_ui.toXml()} |
1043
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
142 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
143 def _change_xmpp_password_cb(self, data, profile): |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
144 xmpp_password = data[xml_tools.form_escape("xmpp_password")] |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
145 d = self.host.memory.param_set( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
146 "Password", xmpp_password, "Connection", profile_key=profile |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
147 ) |
3120 | 148 d.addCallback(lambda __: defer.ensureDeferred(self.host.connect(profile))) |
2765
378188abe941
misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents:
2624
diff
changeset
|
149 d.addCallback(lambda __: {}) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
150 d.addErrback(lambda __: self._change_xmpp_password({}, profile)) |
1060
aa15453ec54d
core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents:
1043
diff
changeset
|
151 return d |