annotate sat/plugins/plugin_misc_register_account.py @ 3600:1709f0a78f50

jp (base): add flag for `use_pubsub` to add cache skipping option
author Goffi <goffi@goffi.org>
date Thu, 29 Jul 2021 22:51:01 +0200
parents be6d91572633
children 524856bd7b19
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
1 #!/usr/bin/env python3
3137
559a625a236b fixed shebangs
Goffi <goffi@goffi.org>
parents: 3136
diff changeset
2
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
3
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
4 # SàT plugin for registering a new XMPP account
3479
be6d91572633 date update
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
1766
d17772b0fe22 copyright update
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
6 # Copyright (C) 2013-2016 Adrien Cossa (souliane@mailoo.org)
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
7
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
8 # This program is free software: you can redistribute it and/or modify
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
9 # it under the terms of the GNU Affero General Public License as published by
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
10 # the Free Software Foundation, either version 3 of the License, or
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
11 # (at your option) any later version.
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
12
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
13 # This program is distributed in the hope that it will be useful,
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
16 # GNU Affero General Public License for more details.
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
17
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
18 # You should have received a copy of the GNU Affero General Public License
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
20
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
21 from sat.core.i18n import _, D_
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
22 from sat.core.log import getLogger
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
23
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
24 log = getLogger(__name__)
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
25 from sat.core.constants import Const as C
2172
545a1261ac3b core, plugin XEP-0077: in-band registration fix and move:
Goffi <goffi@goffi.org>
parents: 2145
diff changeset
26 from twisted.words.protocols.jabber import jid
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
27 from sat.memory.memory import Sessions
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
28 from sat.tools import xml_tools
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
29 from sat.tools.xml_tools import SAT_FORM_PREFIX, SAT_PARAM_SEPARATOR
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
30
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
31
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
32 PLUGIN_INFO = {
2145
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
33 C.PI_NAME: "Register Account Plugin",
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
34 C.PI_IMPORT_NAME: "REGISTER-ACCOUNT",
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
35 C.PI_TYPE: "MISC",
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
36 C.PI_PROTOCOLS: [],
2172
545a1261ac3b core, plugin XEP-0077: in-band registration fix and move:
Goffi <goffi@goffi.org>
parents: 2145
diff changeset
37 C.PI_DEPENDENCIES: ["XEP-0077"],
2145
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
38 C.PI_RECOMMENDATIONS: [],
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
39 C.PI_MAIN: "RegisterAccount",
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
40 C.PI_HANDLER: "no",
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
41 C.PI_DESCRIPTION: _("""Register XMPP account"""),
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
42 }
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
43
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
44
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
45 class RegisterAccount(object):
2172
545a1261ac3b core, plugin XEP-0077: in-band registration fix and move:
Goffi <goffi@goffi.org>
parents: 2145
diff changeset
46 # FIXME: this plugin is messy and difficult to read, it needs to be cleaned up and documented
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
47
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
48 def __init__(self, host):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
49 log.info(_("Plugin Register Account initialization"))
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
50 self.host = host
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
51 self._sessions = Sessions()
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
52 host.registerCallback(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
53 self.registerNewAccountCB, with_data=True, force_id="registerNewAccount"
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
54 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
55 self.__register_account_id = host.registerCallback(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
56 self._registerConfirmation, with_data=True
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
57 )
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
58
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
59 def registerNewAccountCB(self, data, profile):
2172
545a1261ac3b core, plugin XEP-0077: in-band registration fix and move:
Goffi <goffi@goffi.org>
parents: 2145
diff changeset
60 """Called when the user click on the "New account" button."""
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
61 session_data = {}
2172
545a1261ac3b core, plugin XEP-0077: in-band registration fix and move:
Goffi <goffi@goffi.org>
parents: 2145
diff changeset
62
545a1261ac3b core, plugin XEP-0077: in-band registration fix and move:
Goffi <goffi@goffi.org>
parents: 2145
diff changeset
63 # FIXME: following loop is overcomplicated, hard to read
545a1261ac3b core, plugin XEP-0077: in-band registration fix and move:
Goffi <goffi@goffi.org>
parents: 2145
diff changeset
64 # FIXME: while used with parameters, hashed password is used and overwrite clear one
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
65 for param in ("JabberID", "Password", C.FORCE_PORT_PARAM, C.FORCE_SERVER_PARAM):
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
66 try:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
67 session_data[param] = data[
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
68 SAT_FORM_PREFIX + "Connection" + SAT_PARAM_SEPARATOR + param
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
69 ]
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
70 except KeyError:
1089
8e0072754413 core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents: 1088
diff changeset
71 if param in (C.FORCE_PORT_PARAM, C.FORCE_SERVER_PARAM):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
72 session_data[param] = ""
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
73
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
74 for param in ("JabberID", "Password"):
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
75 if not session_data[param]:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
76 form_ui = xml_tools.XMLUI("popup", title=D_("Missing values"))
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
77 form_ui.addText(
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
78 D_("No user JID or password given: can't register new account.")
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
79 )
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
80 return {"xmlui": form_ui.toXml()}
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
81
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
82 session_data["user"], host, resource = jid.parse(session_data["JabberID"])
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
83 session_data["server"] = session_data[C.FORCE_SERVER_PARAM] or host
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
84 session_id, __ = self._sessions.newSession(session_data, profile=profile)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
85 form_ui = xml_tools.XMLUI(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
86 "form",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
87 title=D_("Register new account"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
88 submit_id=self.__register_account_id,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
89 session_id=session_id,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
90 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
91 form_ui.addText(
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
92 D_("Do you want to register a new XMPP account {jid}?").format(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
93 jid=session_data["JabberID"]
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
94 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
95 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
96 return {"xmlui": form_ui.toXml()}
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
97
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
98 def _registerConfirmation(self, data, profile):
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
99 """Save the related parameters and proceed the registration."""
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
100 session_data = self._sessions.profileGet(data["session_id"], profile)
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
101
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
102 self.host.memory.setParam(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
103 "JabberID", session_data["JabberID"], "Connection", profile_key=profile
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
104 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
105 self.host.memory.setParam(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
106 "Password", session_data["Password"], "Connection", profile_key=profile
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
107 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
108 self.host.memory.setParam(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
109 C.FORCE_SERVER_PARAM,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
110 session_data[C.FORCE_SERVER_PARAM],
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
111 "Connection",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
112 profile_key=profile,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
113 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
114 self.host.memory.setParam(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
115 C.FORCE_PORT_PARAM,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
116 session_data[C.FORCE_PORT_PARAM],
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
117 "Connection",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
118 profile_key=profile,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
119 )
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
120
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
121 d = self._registerNewAccount(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
122 jid.JID(session_data["JabberID"]),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
123 session_data["Password"],
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
124 None,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
125 session_data["server"],
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
126 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
127 del self._sessions[data["session_id"]]
1044
85c110c0be86 plugins misc_account, misc_register_account: manually delete the sessions when not needed anymore
souliane <souliane@mailoo.org>
parents: 1037
diff changeset
128 return d
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
129
2172
545a1261ac3b core, plugin XEP-0077: in-band registration fix and move:
Goffi <goffi@goffi.org>
parents: 2145
diff changeset
130 def _registerNewAccount(self, client, jid_, password, email, server):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
131 #  FIXME: port is not set here
2765
378188abe941 misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
132 def registeredCb(__):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
133 xmlui = xml_tools.XMLUI("popup", title=D_("Confirmation"))
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
134 xmlui.addText(D_("Registration successful."))
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
135 return {"xmlui": xmlui.toXml()}
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
136
2172
545a1261ac3b core, plugin XEP-0077: in-band registration fix and move:
Goffi <goffi@goffi.org>
parents: 2145
diff changeset
137 def registeredEb(failure):
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
138 xmlui = xml_tools.XMLUI("popup", title=D_("Failure"))
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
139 xmlui.addText(D_("Registration failed: %s") % failure.getErrorMessage())
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
140 try:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
141 if failure.value.condition == "conflict":
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
142 xmlui.addText(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
143 D_("Username already exists, please choose an other one.")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
144 )
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
145 except AttributeError:
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
146 pass
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
147 return {"xmlui": xmlui.toXml()}
1037
6e975c6b0faf core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff changeset
148
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
149 registered_d = self.host.plugins["XEP-0077"].registerNewAccount(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
150 client, jid_, password, email=email, host=server, port=C.XMPP_C2S_PORT
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
151 )
2172
545a1261ac3b core, plugin XEP-0077: in-band registration fix and move:
Goffi <goffi@goffi.org>
parents: 2145
diff changeset
152 registered_d.addCallbacks(registeredCb, registeredEb)
545a1261ac3b core, plugin XEP-0077: in-band registration fix and move:
Goffi <goffi@goffi.org>
parents: 2145
diff changeset
153 return registered_d