Mercurial > libervia-backend
annotate libervia/backend/plugins/plugin_misc_account.py @ 4332:71c939e34ca6
XEP-0373 (OX): Adjust to gpgme updates: generate with explicit algorithm and subkeys
author | Syndace <me@syndace.dev> |
---|---|
date | Sat, 13 Jul 2024 18:28:28 +0200 |
parents | 0d7bb4df2343 |
children |
rev | line source |
---|---|
3028 | 1 #!/usr/bin/env python3 |
3137 | 2 |
3503
482098e521ff
plugin misc account: specify domain in new account email sent to admins
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
3 # Libervia plugin for account creation |
3479 | 4 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org) |
569
06faf5bffbc0
plugin account: first draft of automatic SàT/Prosody account creation (basis coming from Libervia)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
6 # This program is free software: you can redistribute it and/or modify |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
7 # it under the terms of the GNU Affero General Public License as published by |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
8 # the Free Software Foundation, either version 3 of the License, or |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
9 # (at your option) any later version. |
569
06faf5bffbc0
plugin account: first draft of automatic SàT/Prosody account creation (basis coming from Libervia)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
11 # This program is distributed in the hope that it will be useful, |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
14 # GNU Affero General Public License for more details. |
569
06faf5bffbc0
plugin account: first draft of automatic SàT/Prosody account creation (basis coming from Libervia)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
16 # You should have received a copy of the GNU Affero General Public License |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
569
06faf5bffbc0
plugin account: first draft of automatic SàT/Prosody account creation (basis coming from Libervia)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 |
4071
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
19 from libervia.backend.core.i18n import _, D_ |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
20 from libervia.backend.core.log import getLogger |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
21 |
4071
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
22 from libervia.backend.core import exceptions |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
23 from libervia.backend.tools import xml_tools |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
24 from libervia.backend.memory.memory import Sessions |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
25 from libervia.backend.memory.crypto import PasswordHasher |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
26 from libervia.backend.core.constants import Const as C |
3028 | 27 import configparser |
2176
61128d260eef
plugin account: removed dependency to Prosody/prosodyctl and properly use in-band registration instead
Goffi <goffi@goffi.org>
parents:
2145
diff
changeset
|
28 from twisted.internet import defer |
644
53de6954e94e
plugin misc_account: fix for sending a failure message
souliane <souliane@mailoo.org>
parents:
641
diff
changeset
|
29 from twisted.python.failure import Failure |
2176
61128d260eef
plugin account: removed dependency to Prosody/prosodyctl and properly use in-band registration instead
Goffi <goffi@goffi.org>
parents:
2145
diff
changeset
|
30 from twisted.words.protocols.jabber import jid |
4071
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
31 from libervia.backend.tools.common import email as sat_email |
1653
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
32 |
3120 | 33 |
34 log = getLogger(__name__) | |
35 | |
36 | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
37 # FIXME: this plugin code is old and need a cleaning |
2176
61128d260eef
plugin account: removed dependency to Prosody/prosodyctl and properly use in-band registration instead
Goffi <goffi@goffi.org>
parents:
2145
diff
changeset
|
38 # TODO: account deletion/password change need testing |
61128d260eef
plugin account: removed dependency to Prosody/prosodyctl and properly use in-band registration instead
Goffi <goffi@goffi.org>
parents:
2145
diff
changeset
|
39 |
1653
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
40 |
569
06faf5bffbc0
plugin account: first draft of automatic SàT/Prosody account creation (basis coming from Libervia)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 PLUGIN_INFO = { |
2145
33c8c4973743
core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents:
2144
diff
changeset
|
42 C.PI_NAME: "Account Plugin", |
33c8c4973743
core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents:
2144
diff
changeset
|
43 C.PI_IMPORT_NAME: "MISC-ACCOUNT", |
33c8c4973743
core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents:
2144
diff
changeset
|
44 C.PI_TYPE: "MISC", |
33c8c4973743
core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents:
2144
diff
changeset
|
45 C.PI_PROTOCOLS: [], |
2176
61128d260eef
plugin account: removed dependency to Prosody/prosodyctl and properly use in-band registration instead
Goffi <goffi@goffi.org>
parents:
2145
diff
changeset
|
46 C.PI_DEPENDENCIES: ["XEP-0077"], |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
47 C.PI_RECOMMENDATIONS: ["GROUPBLOG"], |
2145
33c8c4973743
core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents:
2144
diff
changeset
|
48 C.PI_MAIN: "MiscAccount", |
33c8c4973743
core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents:
2144
diff
changeset
|
49 C.PI_HANDLER: "no", |
3503
482098e521ff
plugin misc account: specify domain in new account email sent to admins
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
50 C.PI_DESCRIPTION: _("""Libervia account creation"""), |
569
06faf5bffbc0
plugin account: first draft of automatic SàT/Prosody account creation (basis coming from Libervia)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 } |
06faf5bffbc0
plugin account: first draft of automatic SàT/Prosody account creation (basis coming from Libervia)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 |
730
32bbabe809da
plugin account: configuration constants can be overriden in sat.conf (section "plugin account") + better deferred management in email sending
Goffi <goffi@goffi.org>
parents:
672
diff
changeset
|
53 CONFIG_SECTION = "plugin account" |
32bbabe809da
plugin account: configuration constants can be overriden in sat.conf (section "plugin account") + better deferred management in email sending
Goffi <goffi@goffi.org>
parents:
672
diff
changeset
|
54 |
32bbabe809da
plugin account: configuration constants can be overriden in sat.conf (section "plugin account") + better deferred management in email sending
Goffi <goffi@goffi.org>
parents:
672
diff
changeset
|
55 # You need do adapt the following consts to your server |
3503
482098e521ff
plugin misc account: specify domain in new account email sent to admins
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
56 # all theses values (key=option name, value=default) can (and should) be overriden |
482098e521ff
plugin misc account: specify domain in new account email sent to admins
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
57 # in libervia.conf in section CONFIG_SECTION |
569
06faf5bffbc0
plugin account: first draft of automatic SàT/Prosody account creation (basis coming from Libervia)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
58 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
59 default_conf = { |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
60 "email_from": "NOREPLY@example.net", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
61 "email_server": "localhost", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
62 "email_sender_domain": "", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
63 "email_port": 25, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
64 "email_username": "", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
65 "email_password": "", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
66 "email_starttls": "false", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
67 "email_auth": "false", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
68 "email_admins_list": [], |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
69 "admin_email": "", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
70 "new_account_server": "localhost", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
71 "new_account_domain": "", # use xmpp_domain if not found |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
72 "reserved_list": ["libervia"], # profiles which can't be used |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
73 } |
569
06faf5bffbc0
plugin account: first draft of automatic SàT/Prosody account creation (basis coming from Libervia)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
74 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
75 WELCOME_MSG = D_( |
3028 | 76 """Welcome to Libervia, the web interface of Salut à Toi. |
2181
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
77 |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
78 Your account on {domain} has been successfully created. |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
79 This is a demonstration version to show you the current status of the project. |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
80 It is still under development, please keep it in mind! |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
81 |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
82 Here is your connection information: |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
83 |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
84 Login on {domain}: {profile} |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
85 Jabber ID (JID): {jid} |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
86 Your password has been chosen by yourself during registration. |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
87 |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
88 In the beginning, you have nobody to talk to. To find some contacts, you may use the users' directory: |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
89 - make yourself visible in "Service / Directory subscription". |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
90 - search for people with "Contacts" / Search directory". |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
91 |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
92 Any feedback welcome. Thank you! |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
93 |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
94 Salut à Toi association |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
95 https://www.salut-a-toi.org |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
96 """ |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
97 ) |
2181
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
98 |
3028 | 99 DEFAULT_DOMAIN = "example.net" |
2261
8be4f5769bf7
plugin account: print a warning and use "example.net" as default instead or raising an error when xmpp_domain is not set
Goffi <goffi@goffi.org>
parents:
2181
diff
changeset
|
100 |
594
e629371a28d3
Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
588
diff
changeset
|
101 |
2176
61128d260eef
plugin account: removed dependency to Prosody/prosodyctl and properly use in-band registration instead
Goffi <goffi@goffi.org>
parents:
2145
diff
changeset
|
102 class MiscAccount(object): |
61128d260eef
plugin account: removed dependency to Prosody/prosodyctl and properly use in-band registration instead
Goffi <goffi@goffi.org>
parents:
2145
diff
changeset
|
103 """Account plugin: create a SàT + XMPP account, used by Libervia""" |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
104 |
2176
61128d260eef
plugin account: removed dependency to Prosody/prosodyctl and properly use in-band registration instead
Goffi <goffi@goffi.org>
parents:
2145
diff
changeset
|
105 # XXX: This plugin was initialy a Q&D one used for the demo. |
61128d260eef
plugin account: removed dependency to Prosody/prosodyctl and properly use in-band registration instead
Goffi <goffi@goffi.org>
parents:
2145
diff
changeset
|
106 # TODO: cleaning, separate email handling, more configuration/tests, fixes |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
107 |
569
06faf5bffbc0
plugin account: first draft of automatic SàT/Prosody account creation (basis coming from Libervia)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
108 def __init__(self, host): |
3028 | 109 log.info(_("Plugin Account initialization")) |
569
06faf5bffbc0
plugin account: first draft of automatic SàT/Prosody account creation (basis coming from Libervia)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 self.host = host |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
111 host.bridge.add_method( |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
112 "libervia_account_register", |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
113 ".plugin", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
114 in_sign="sss", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
115 out_sign="", |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
116 method=self._register_account, |
3028 | 117 async_=True, |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
118 ) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
119 host.bridge.add_method( |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
120 "account_domain_new_get", |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
121 ".plugin", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
122 in_sign="", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
123 out_sign="s", |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
124 method=self.account_domain_new_get, |
3028 | 125 async_=False, |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
126 ) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
127 host.bridge.add_method( |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
128 "account_dialog_ui_get", |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
129 ".plugin", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
130 in_sign="s", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
131 out_sign="s", |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
132 method=self._get_account_dialog_ui, |
3028 | 133 async_=False, |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
134 ) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
135 host.bridge.add_method( |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
136 "credentials_xmpp_connect", |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
137 ".plugin", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
138 in_sign="ss", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
139 out_sign="b", |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
140 method=self.credentials_xmpp_connect, |
3028 | 141 async_=True, |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
142 ) |
569
06faf5bffbc0
plugin account: first draft of automatic SàT/Prosody account creation (basis coming from Libervia)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
143 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
144 self.fix_email_admins() |
1041
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
145 self._sessions = Sessions() |
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
146 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
147 self.__account_cb_id = host.register_callback( |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
148 self._account_dialog_cb, with_data=True |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
149 ) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
150 self.__change_password_id = host.register_callback( |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
151 self.__change_password_cb, with_data=True |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
152 ) |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
153 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
154 def delete_blog_callback(posts, comments): |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
155 return lambda data, profile: self.__delete_blog_posts_cb( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
156 posts, comments, data, profile |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
157 ) |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
158 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
159 self.__delete_posts_id = host.register_callback( |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
160 delete_blog_callback(True, False), with_data=True |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
161 ) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
162 self.__delete_comments_id = host.register_callback( |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
163 delete_blog_callback(False, True), with_data=True |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
164 ) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
165 self.__delete_posts_comments_id = host.register_callback( |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
166 delete_blog_callback(True, True), with_data=True |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
167 ) |
1041
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
168 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
169 self.__delete_account_id = host.register_callback( |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
170 self.__delete_account_cb, with_data=True |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
171 ) |
1892
8a5b178ff28b
plugin misc_account: fixes handling of deprecater parameter "admin_email"
souliane <souliane@mailoo.org>
parents:
1856
diff
changeset
|
172 |
8a5b178ff28b
plugin misc_account: fixes handling of deprecater parameter "admin_email"
souliane <souliane@mailoo.org>
parents:
1856
diff
changeset
|
173 # FIXME: remove this after some time, when the deprecated parameter is really abandoned |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
174 def fix_email_admins(self): |
1892
8a5b178ff28b
plugin misc_account: fixes handling of deprecater parameter "admin_email"
souliane <souliane@mailoo.org>
parents:
1856
diff
changeset
|
175 """Handle deprecated config option "admin_email" to fix the admin emails list""" |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
176 admin_email = self.config_get("admin_email") |
1892
8a5b178ff28b
plugin misc_account: fixes handling of deprecater parameter "admin_email"
souliane <souliane@mailoo.org>
parents:
1856
diff
changeset
|
177 if not admin_email: |
8a5b178ff28b
plugin misc_account: fixes handling of deprecater parameter "admin_email"
souliane <souliane@mailoo.org>
parents:
1856
diff
changeset
|
178 return |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
179 log.warning( |
3028 | 180 "admin_email parameter is deprecated, please use email_admins_list instead" |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
181 ) |
1892
8a5b178ff28b
plugin misc_account: fixes handling of deprecater parameter "admin_email"
souliane <souliane@mailoo.org>
parents:
1856
diff
changeset
|
182 param_name = "email_admins_list" |
8a5b178ff28b
plugin misc_account: fixes handling of deprecater parameter "admin_email"
souliane <souliane@mailoo.org>
parents:
1856
diff
changeset
|
183 try: |
8a5b178ff28b
plugin misc_account: fixes handling of deprecater parameter "admin_email"
souliane <souliane@mailoo.org>
parents:
1856
diff
changeset
|
184 section = "" |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
185 value = self.host.memory.config_get(section, param_name, Exception) |
3028 | 186 except (configparser.NoOptionError, configparser.NoSectionError): |
1892
8a5b178ff28b
plugin misc_account: fixes handling of deprecater parameter "admin_email"
souliane <souliane@mailoo.org>
parents:
1856
diff
changeset
|
187 section = CONFIG_SECTION |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
188 value = self.host.memory.config_get( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
189 section, param_name, default_conf[param_name] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
190 ) |
1892
8a5b178ff28b
plugin misc_account: fixes handling of deprecater parameter "admin_email"
souliane <souliane@mailoo.org>
parents:
1856
diff
changeset
|
191 |
8a5b178ff28b
plugin misc_account: fixes handling of deprecater parameter "admin_email"
souliane <souliane@mailoo.org>
parents:
1856
diff
changeset
|
192 value = set(value) |
8a5b178ff28b
plugin misc_account: fixes handling of deprecater parameter "admin_email"
souliane <souliane@mailoo.org>
parents:
1856
diff
changeset
|
193 value.add(admin_email) |
8a5b178ff28b
plugin misc_account: fixes handling of deprecater parameter "admin_email"
souliane <souliane@mailoo.org>
parents:
1856
diff
changeset
|
194 self.host.memory.config.set(section, param_name, ",".join(value)) |
8a5b178ff28b
plugin misc_account: fixes handling of deprecater parameter "admin_email"
souliane <souliane@mailoo.org>
parents:
1856
diff
changeset
|
195 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
196 def config_get(self, name, section=CONFIG_SECTION): |
1855
1c9b2c184663
plugin account: email sending improvments:
Goffi <goffi@goffi.org>
parents:
1804
diff
changeset
|
197 if name.startswith("email_"): |
1c9b2c184663
plugin account: email sending improvments:
Goffi <goffi@goffi.org>
parents:
1804
diff
changeset
|
198 # XXX: email_ parameters were first in [plugin account] section |
1c9b2c184663
plugin account: email sending improvments:
Goffi <goffi@goffi.org>
parents:
1804
diff
changeset
|
199 # but as it make more sense to have them in common with other plugins, |
1c9b2c184663
plugin account: email sending improvments:
Goffi <goffi@goffi.org>
parents:
1804
diff
changeset
|
200 # they can now be in [DEFAULT] section |
1c9b2c184663
plugin account: email sending improvments:
Goffi <goffi@goffi.org>
parents:
1804
diff
changeset
|
201 try: |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
202 value = self.host.memory.config_get(None, name, Exception) |
3028 | 203 except (configparser.NoOptionError, configparser.NoSectionError): |
1855
1c9b2c184663
plugin account: email sending improvments:
Goffi <goffi@goffi.org>
parents:
1804
diff
changeset
|
204 pass |
1c9b2c184663
plugin account: email sending improvments:
Goffi <goffi@goffi.org>
parents:
1804
diff
changeset
|
205 else: |
1c9b2c184663
plugin account: email sending improvments:
Goffi <goffi@goffi.org>
parents:
1804
diff
changeset
|
206 return value |
1c9b2c184663
plugin account: email sending improvments:
Goffi <goffi@goffi.org>
parents:
1804
diff
changeset
|
207 |
2181
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
208 if section == CONFIG_SECTION: |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
209 default = default_conf[name] |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
210 else: |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
211 default = None |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
212 return self.host.memory.config_get(section, name, default) |
1653
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
213 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
214 def _register_account(self, email, password, profile): |
1727
68e498b3367e
reverted revision 2ebe66a96d05
souliane <souliane@mailoo.org>
parents:
1726
diff
changeset
|
215 return self.registerAccount(email, password, None, profile) |
1653
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
216 |
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
217 def registerAccount(self, email, password, jid_s, profile): |
1907
0b748ad46ede
plugin misc account: separate profile creation and sending emails, so we can wait and send the emails at the right time (when we know that no error occured)
souliane <souliane@mailoo.org>
parents:
1901
diff
changeset
|
218 """Register a new profile, its associated XMPP account, send the confirmation emails. |
0b748ad46ede
plugin misc account: separate profile creation and sending emails, so we can wait and send the emails at the right time (when we know that no error occured)
souliane <souliane@mailoo.org>
parents:
1901
diff
changeset
|
219 |
0b748ad46ede
plugin misc account: separate profile creation and sending emails, so we can wait and send the emails at the right time (when we know that no error occured)
souliane <souliane@mailoo.org>
parents:
1901
diff
changeset
|
220 @param email (unicode): where to send to confirmation email to |
0b748ad46ede
plugin misc account: separate profile creation and sending emails, so we can wait and send the emails at the right time (when we know that no error occured)
souliane <souliane@mailoo.org>
parents:
1901
diff
changeset
|
221 @param password (unicode): password chosen by the user |
0b748ad46ede
plugin misc account: separate profile creation and sending emails, so we can wait and send the emails at the right time (when we know that no error occured)
souliane <souliane@mailoo.org>
parents:
1901
diff
changeset
|
222 while be used for profile *and* XMPP account |
0b748ad46ede
plugin misc account: separate profile creation and sending emails, so we can wait and send the emails at the right time (when we know that no error occured)
souliane <souliane@mailoo.org>
parents:
1901
diff
changeset
|
223 @param jid_s (unicode): JID to re-use or to register: |
0b748ad46ede
plugin misc account: separate profile creation and sending emails, so we can wait and send the emails at the right time (when we know that no error occured)
souliane <souliane@mailoo.org>
parents:
1901
diff
changeset
|
224 - non empty value: bind this JID to the new sat profile |
0b748ad46ede
plugin misc account: separate profile creation and sending emails, so we can wait and send the emails at the right time (when we know that no error occured)
souliane <souliane@mailoo.org>
parents:
1901
diff
changeset
|
225 - None or "": register a new JID on the local XMPP server |
0b748ad46ede
plugin misc account: separate profile creation and sending emails, so we can wait and send the emails at the right time (when we know that no error occured)
souliane <souliane@mailoo.org>
parents:
1901
diff
changeset
|
226 @param profile |
0b748ad46ede
plugin misc account: separate profile creation and sending emails, so we can wait and send the emails at the right time (when we know that no error occured)
souliane <souliane@mailoo.org>
parents:
1901
diff
changeset
|
227 @return Deferred |
0b748ad46ede
plugin misc account: separate profile creation and sending emails, so we can wait and send the emails at the right time (when we know that no error occured)
souliane <souliane@mailoo.org>
parents:
1901
diff
changeset
|
228 """ |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
229 d = self.create_profile(password, jid_s, profile) |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
230 d.addCallback(lambda __: self.send_emails(email, profile)) |
1907
0b748ad46ede
plugin misc account: separate profile creation and sending emails, so we can wait and send the emails at the right time (when we know that no error occured)
souliane <souliane@mailoo.org>
parents:
1901
diff
changeset
|
231 return d |
0b748ad46ede
plugin misc account: separate profile creation and sending emails, so we can wait and send the emails at the right time (when we know that no error occured)
souliane <souliane@mailoo.org>
parents:
1901
diff
changeset
|
232 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
233 def create_profile(self, password, jid_s, profile): |
1653
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
234 """Register a new profile and its associated XMPP account. |
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
235 |
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
236 @param password (unicode): password chosen by the user |
1696
9a7a27c44611
plugin account: fixed profile creation: session is started to set the connection parameters, then stopped
Goffi <goffi@goffi.org>
parents:
1691
diff
changeset
|
237 while be used for profile *and* XMPP account |
1653
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
238 @param jid_s (unicode): JID to re-use or to register: |
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
239 - non empty value: bind this JID to the new sat profile |
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
240 - None or "": register a new JID on the local XMPP server |
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
241 @param profile |
1696
9a7a27c44611
plugin account: fixed profile creation: session is started to set the connection parameters, then stopped
Goffi <goffi@goffi.org>
parents:
1691
diff
changeset
|
242 @return Deferred |
569
06faf5bffbc0
plugin account: first draft of automatic SàT/Prosody account creation (basis coming from Libervia)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
243 """ |
1653
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
244 if not password or not profile: |
569
06faf5bffbc0
plugin account: first draft of automatic SàT/Prosody account creation (basis coming from Libervia)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
245 raise exceptions.DataError |
06faf5bffbc0
plugin account: first draft of automatic SàT/Prosody account creation (basis coming from Libervia)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
246 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
247 if profile.lower() in self.config_get("reserved_list"): |
751
1def5b7edf9f
core, bridge: better GenericException handling
Goffi <goffi@goffi.org>
parents:
733
diff
changeset
|
248 return defer.fail(Failure(exceptions.ConflictError)) |
569
06faf5bffbc0
plugin account: first draft of automatic SàT/Prosody account creation (basis coming from Libervia)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
249 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
250 d = self.host.memory.create_profile(profile, password) |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
251 d.addCallback(lambda __: self.profile_created(password, jid_s, profile)) |
569
06faf5bffbc0
plugin account: first draft of automatic SàT/Prosody account creation (basis coming from Libervia)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
252 return d |
06faf5bffbc0
plugin account: first draft of automatic SàT/Prosody account creation (basis coming from Libervia)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
253 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
254 def profile_created(self, password, jid_s, profile): |
1907
0b748ad46ede
plugin misc account: separate profile creation and sending emails, so we can wait and send the emails at the right time (when we know that no error occured)
souliane <souliane@mailoo.org>
parents:
1901
diff
changeset
|
255 """Create the XMPP account and set the profile connection parameters. |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
256 |
1653
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
257 @param password (unicode): password chosen by the user |
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
258 @param jid_s (unicode): JID to re-use or to register: |
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
259 - non empty value: bind this JID to the new sat profile |
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
260 - None or empty: register a new JID on the local XMPP server |
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
261 @param profile |
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
262 @return: Deferred |
1031
e90125d07072
plugins misc_account, misc_smtp: update the plugins that deal with passwords
souliane <souliane@mailoo.org>
parents:
993
diff
changeset
|
263 """ |
1653
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
264 if jid_s: |
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
265 d = defer.succeed(None) |
2176
61128d260eef
plugin account: removed dependency to Prosody/prosodyctl and properly use in-band registration instead
Goffi <goffi@goffi.org>
parents:
2145
diff
changeset
|
266 jid_ = jid.JID(jid_s) |
1653
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
267 else: |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
268 jid_s = profile + "@" + self.account_domain_new_get() |
2176
61128d260eef
plugin account: removed dependency to Prosody/prosodyctl and properly use in-band registration instead
Goffi <goffi@goffi.org>
parents:
2145
diff
changeset
|
269 jid_ = jid.JID(jid_s) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
270 d = self.host.plugins["XEP-0077"].register_new_account(jid_, password) |
1729
9037161e28f0
plugin misc_account: send email to the admins when a new profile is created for an external XMPP account
souliane <souliane@mailoo.org>
parents:
1727
diff
changeset
|
271 |
2765
378188abe941
misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents:
2624
diff
changeset
|
272 def setParams(__): |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
273 self.host.memory.param_set( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
274 "JabberID", jid_s, "Connection", profile_key=profile |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
275 ) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
276 d = self.host.memory.param_set( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
277 "Password", password, "Connection", profile_key=profile |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
278 ) |
1696
9a7a27c44611
plugin account: fixed profile creation: session is started to set the connection parameters, then stopped
Goffi <goffi@goffi.org>
parents:
1691
diff
changeset
|
279 return d |
1080
f25ec9fd7cc4
plugin misc_account: suppress the profile after its creation if the XMPP account registration failed
souliane <souliane@mailoo.org>
parents:
1044
diff
changeset
|
280 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
281 def remove_profile(failure): |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
282 self.host.memory.profile_delete_async(profile) |
1080
f25ec9fd7cc4
plugin misc_account: suppress the profile after its creation if the XMPP account registration failed
souliane <souliane@mailoo.org>
parents:
1044
diff
changeset
|
283 return failure |
f25ec9fd7cc4
plugin misc_account: suppress the profile after its creation if the XMPP account registration failed
souliane <souliane@mailoo.org>
parents:
1044
diff
changeset
|
284 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
285 d.addCallback(lambda __: self.host.memory.start_session(password, profile)) |
1080
f25ec9fd7cc4
plugin misc_account: suppress the profile after its creation if the XMPP account registration failed
souliane <souliane@mailoo.org>
parents:
1044
diff
changeset
|
286 d.addCallback(setParams) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
287 d.addCallback(lambda __: self.host.memory.stop_session(profile)) |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
288 d.addErrback(remove_profile) |
733 | 289 return d |
569
06faf5bffbc0
plugin account: first draft of automatic SàT/Prosody account creation (basis coming from Libervia)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
290 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
291 def _send_email_eb(self, failure_, email): |
2181
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
292 # TODO: return error code to user |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
293 log.error( |
3028 | 294 _("Failed to send account creation confirmation to {email}: {msg}").format( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
295 email=email, msg=failure_ |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
296 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
297 ) |
2181
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
298 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
299 def send_emails(self, email, profile): |
1433
5d42e2219d7c
plugin misc_account: change the message sent by email after an account creation
souliane <souliane@mailoo.org>
parents:
1409
diff
changeset
|
300 # time to send the email |
571
1cb24325485c
plugin account: errReceived fix + emails are now sent on new account + generic example server constants
Goffi <goffi@goffi.org>
parents:
569
diff
changeset
|
301 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
302 domain = self.account_domain_new_get() |
1898
31b8a58cfcf5
plugin misc_account: fixes sending email (twisted.mail.smtp.sendmail doesn't want unicode)
souliane <souliane@mailoo.org>
parents:
1897
diff
changeset
|
303 |
31b8a58cfcf5
plugin misc_account: fixes sending email (twisted.mail.smtp.sendmail doesn't want unicode)
souliane <souliane@mailoo.org>
parents:
1897
diff
changeset
|
304 # email to the administrators |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
305 admins_emails = self.config_get("email_admins_list") |
1855
1c9b2c184663
plugin account: email sending improvments:
Goffi <goffi@goffi.org>
parents:
1804
diff
changeset
|
306 if not admins_emails: |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
307 log.warning( |
3503
482098e521ff
plugin misc account: specify domain in new account email sent to admins
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
308 "No known admin email, we can't send email to administrator(s).\n" |
482098e521ff
plugin misc account: specify domain in new account email sent to admins
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
309 "Please fill email_admins_list parameter" |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
310 ) |
1855
1c9b2c184663
plugin account: email sending improvments:
Goffi <goffi@goffi.org>
parents:
1804
diff
changeset
|
311 d_admin = defer.fail(exceptions.DataError("no admin email")) |
1c9b2c184663
plugin account: email sending improvments:
Goffi <goffi@goffi.org>
parents:
1804
diff
changeset
|
312 else: |
3028 | 313 subject = _("New Libervia account created") |
3503
482098e521ff
plugin misc account: specify domain in new account email sent to admins
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
314 # there is no email when an existing XMPP account is used |
482098e521ff
plugin misc account: specify domain in new account email sent to admins
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
315 body = f"New account created on {domain}: {profile} [{email or '<no email>'}]" |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
316 d_admin = sat_email.send_email( |
4270
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
317 self.host.memory.config, admins_emails, subject, body |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
318 ) |
1729
9037161e28f0
plugin misc_account: send email to the admins when a new profile is created for an external XMPP account
souliane <souliane@mailoo.org>
parents:
1727
diff
changeset
|
319 |
3028 | 320 admins_emails_txt = ", ".join(["<" + addr + ">" for addr in admins_emails]) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
321 d_admin.addCallbacks( |
2765
378188abe941
misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents:
2624
diff
changeset
|
322 lambda __: log.debug( |
3028 | 323 "Account creation notification sent to admin(s) {}".format( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
324 admins_emails_txt |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
325 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
326 ), |
2765
378188abe941
misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents:
2624
diff
changeset
|
327 lambda __: log.error( |
3028 | 328 "Failed to send account creation notification to admin {}".format( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
329 admins_emails_txt |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
330 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
331 ), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
332 ) |
1729
9037161e28f0
plugin misc_account: send email to the admins when a new profile is created for an external XMPP account
souliane <souliane@mailoo.org>
parents:
1727
diff
changeset
|
333 if not email: |
2181
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
334 # TODO: if use register with an existing account, an XMPP message should be sent |
1729
9037161e28f0
plugin misc_account: send email to the admins when a new profile is created for an external XMPP account
souliane <souliane@mailoo.org>
parents:
1727
diff
changeset
|
335 return d_admin |
9037161e28f0
plugin misc_account: send email to the admins when a new profile is created for an external XMPP account
souliane <souliane@mailoo.org>
parents:
1727
diff
changeset
|
336 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
337 jid_s = self.host.memory.param_get_a( |
3028 | 338 "JabberID", "Connection", profile_key=profile |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
339 ) |
3028 | 340 subject = _("Your Libervia account has been created") |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
341 body = _(WELCOME_MSG).format(profile=profile, jid=jid_s, domain=domain) |
730
32bbabe809da
plugin account: configuration constants can be overriden in sat.conf (section "plugin account") + better deferred management in email sending
Goffi <goffi@goffi.org>
parents:
672
diff
changeset
|
342 |
1804
33e73c70d78a
plugin misc_account: add a FIXME comment
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
343 # XXX: this will not fail when the email address doesn't exist |
33e73c70d78a
plugin misc_account: add a FIXME comment
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
344 # FIXME: check email reception to validate email given by the user |
33e73c70d78a
plugin misc_account: add a FIXME comment
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
345 # FIXME: delete the profile if the email could not been sent? |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
346 d_user = sat_email.send_email(self.host.memory.config, [email], subject, body) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
347 d_user.addCallbacks( |
2765
378188abe941
misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents:
2624
diff
changeset
|
348 lambda __: log.debug( |
3028 | 349 "Account creation confirmation sent to <{}>".format(email) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
350 ), |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
351 self._send_email_eb, |
4270
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
352 errbackArgs=[email], |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
353 ) |
730
32bbabe809da
plugin account: configuration constants can be overriden in sat.conf (section "plugin account") + better deferred management in email sending
Goffi <goffi@goffi.org>
parents:
672
diff
changeset
|
354 return defer.DeferredList([d_user, d_admin]) |
672
712e3782af12
plugin misc_account: added method getNewAccountDomain
souliane <souliane@mailoo.org>
parents:
644
diff
changeset
|
355 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
356 def account_domain_new_get(self): |
2181
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
357 """get the domain that will be set to new account""" |
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
358 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
359 domain = self.config_get("new_account_domain") or self.config_get( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
360 "xmpp_domain", None |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
361 ) |
2181
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
362 if not domain: |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
363 log.warning( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
364 _( |
3028 | 365 'xmpp_domain needs to be set in sat.conf. Using "{default}" meanwhile' |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
366 ).format(default=DEFAULT_DOMAIN) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
367 ) |
2261
8be4f5769bf7
plugin account: print a warning and use "example.net" as default instead or raising an error when xmpp_domain is not set
Goffi <goffi@goffi.org>
parents:
2181
diff
changeset
|
368 return DEFAULT_DOMAIN |
2181
968b0d13bcc7
plugin account, tools: some cleaning account + email and password tools:
Goffi <goffi@goffi.org>
parents:
2177
diff
changeset
|
369 return domain |
672
712e3782af12
plugin misc_account: added method getNewAccountDomain
souliane <souliane@mailoo.org>
parents:
644
diff
changeset
|
370 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
371 def _get_account_dialog_ui(self, profile): |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
372 """Get the main dialog to manage your account |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
373 @param menu_data |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
374 @param profile: %(doc_profile)s |
1031
e90125d07072
plugins misc_account, misc_smtp: update the plugins that deal with passwords
souliane <souliane@mailoo.org>
parents:
993
diff
changeset
|
375 @return: XML of the dialog |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
376 """ |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
377 form_ui = xml_tools.XMLUI( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
378 "form", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
379 "tabs", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
380 title=D_("Manage your account"), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
381 submit_id=self.__account_cb_id, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
382 ) |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
383 tab_container = form_ui.current_container |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
384 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
385 tab_container.add_tab( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
386 "update", D_("Change your password"), container=xml_tools.PairsContainer |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
387 ) |
1041
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
388 form_ui.addLabel(D_("Current profile password")) |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
389 form_ui.addPassword("current_passwd", value="") |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
390 form_ui.addLabel(D_("New password")) |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
391 form_ui.addPassword("new_passwd1", value="") |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
392 form_ui.addLabel(D_("New password (again)")) |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
393 form_ui.addPassword("new_passwd2", value="") |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
394 |
1855
1c9b2c184663
plugin account: email sending improvments:
Goffi <goffi@goffi.org>
parents:
1804
diff
changeset
|
395 # FIXME: uncomment and fix these features |
1713
0d972af37ff5
plugin misc_account: temporary disabling posts and account deletion
souliane <souliane@mailoo.org>
parents:
1707
diff
changeset
|
396 """ |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
397 if 'GROUPBLOG' in self.host.plugins: |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
398 tab_container.add_tab("delete_posts", D_("Delete your posts"), container=xml_tools.PairsContainer) |
1041
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
399 form_ui.addLabel(D_("Current profile password")) |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
400 form_ui.addPassword("delete_posts_passwd", value="") |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
401 form_ui.addLabel(D_("Delete all your posts and their comments")) |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
402 form_ui.addBool("delete_posts_checkbox", "false") |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
403 form_ui.addLabel(D_("Delete all your comments on other's posts")) |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
404 form_ui.addBool("delete_comments_checkbox", "false") |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
405 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
406 tab_container.add_tab("delete", D_("Delete your account"), container=xml_tools.PairsContainer) |
1041
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
407 form_ui.addLabel(D_("Current profile password")) |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
408 form_ui.addPassword("delete_passwd", value="") |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
409 form_ui.addLabel(D_("Delete your account")) |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
410 form_ui.addBool("delete_checkbox", "false") |
1713
0d972af37ff5
plugin misc_account: temporary disabling posts and account deletion
souliane <souliane@mailoo.org>
parents:
1707
diff
changeset
|
411 """ |
0d972af37ff5
plugin misc_account: temporary disabling posts and account deletion
souliane <souliane@mailoo.org>
parents:
1707
diff
changeset
|
412 |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
413 return form_ui.toXml() |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
414 |
1031
e90125d07072
plugins misc_account, misc_smtp: update the plugins that deal with passwords
souliane <souliane@mailoo.org>
parents:
993
diff
changeset
|
415 @defer.inlineCallbacks |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
416 def _account_dialog_cb(self, data, profile): |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
417 """Called when the user submits the main account dialog |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
418 @param data |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
419 @param profile |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
420 """ |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
421 sat_cipher = yield self.host.memory.param_get_a_async( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
422 C.PROFILE_PASS_PATH[1], C.PROFILE_PASS_PATH[0], profile_key=profile |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
423 ) |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
424 |
1041
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
425 @defer.inlineCallbacks |
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
426 def verify(attempt): |
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
427 auth = yield PasswordHasher.verify(attempt, sat_cipher) |
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
428 defer.returnValue(auth) |
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
429 |
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
430 def error_ui(message=None): |
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
431 if not message: |
1691
cec204c6360c
plugin misc_account: fixed password verification
souliane <souliane@mailoo.org>
parents:
1653
diff
changeset
|
432 message = D_("The provided profile password doesn't match.") |
1041
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
433 error_ui = xml_tools.XMLUI("popup", title=D_("Attempt failure")) |
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
434 error_ui.addText(message) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
435 return {"xmlui": error_ui.toXml()} |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
436 |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
437 # check for account deletion |
1855
1c9b2c184663
plugin account: email sending improvments:
Goffi <goffi@goffi.org>
parents:
1804
diff
changeset
|
438 # FIXME: uncomment and fix these features |
1713
0d972af37ff5
plugin misc_account: temporary disabling posts and account deletion
souliane <souliane@mailoo.org>
parents:
1707
diff
changeset
|
439 """ |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
440 delete_passwd = data[xml_tools.SAT_FORM_PREFIX + 'delete_passwd'] |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
441 delete_checkbox = data[xml_tools.SAT_FORM_PREFIX + 'delete_checkbox'] |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
442 if delete_checkbox == 'true': |
1691
cec204c6360c
plugin misc_account: fixed password verification
souliane <souliane@mailoo.org>
parents:
1653
diff
changeset
|
443 verified = yield verify(delete_passwd) |
cec204c6360c
plugin misc_account: fixed password verification
souliane <souliane@mailoo.org>
parents:
1653
diff
changeset
|
444 assert isinstance(verified, bool) |
cec204c6360c
plugin misc_account: fixed password verification
souliane <souliane@mailoo.org>
parents:
1653
diff
changeset
|
445 if verified: |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
446 defer.returnValue(self.__delete_account(profile)) |
1031
e90125d07072
plugins misc_account, misc_smtp: update the plugins that deal with passwords
souliane <souliane@mailoo.org>
parents:
993
diff
changeset
|
447 defer.returnValue(error_ui()) |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
448 |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
449 # check for blog posts deletion |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
450 if 'GROUPBLOG' in self.host.plugins: |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
451 delete_posts_passwd = data[xml_tools.SAT_FORM_PREFIX + 'delete_posts_passwd'] |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
452 delete_posts_checkbox = data[xml_tools.SAT_FORM_PREFIX + 'delete_posts_checkbox'] |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
453 delete_comments_checkbox = data[xml_tools.SAT_FORM_PREFIX + 'delete_comments_checkbox'] |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
454 posts = delete_posts_checkbox == 'true' |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
455 comments = delete_comments_checkbox == 'true' |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
456 if posts or comments: |
1691
cec204c6360c
plugin misc_account: fixed password verification
souliane <souliane@mailoo.org>
parents:
1653
diff
changeset
|
457 verified = yield verify(delete_posts_passwd) |
cec204c6360c
plugin misc_account: fixed password verification
souliane <souliane@mailoo.org>
parents:
1653
diff
changeset
|
458 assert isinstance(verified, bool) |
cec204c6360c
plugin misc_account: fixed password verification
souliane <souliane@mailoo.org>
parents:
1653
diff
changeset
|
459 if verified: |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
460 defer.returnValue(self.__delete_blog_posts(posts, comments, profile)) |
1031
e90125d07072
plugins misc_account, misc_smtp: update the plugins that deal with passwords
souliane <souliane@mailoo.org>
parents:
993
diff
changeset
|
461 defer.returnValue(error_ui()) |
1713
0d972af37ff5
plugin misc_account: temporary disabling posts and account deletion
souliane <souliane@mailoo.org>
parents:
1707
diff
changeset
|
462 """ |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
463 |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
464 # check for password modification |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
465 current_passwd = data[xml_tools.SAT_FORM_PREFIX + "current_passwd"] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
466 new_passwd1 = data[xml_tools.SAT_FORM_PREFIX + "new_passwd1"] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
467 new_passwd2 = data[xml_tools.SAT_FORM_PREFIX + "new_passwd2"] |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
468 if new_passwd1 or new_passwd2: |
1691
cec204c6360c
plugin misc_account: fixed password verification
souliane <souliane@mailoo.org>
parents:
1653
diff
changeset
|
469 verified = yield verify(current_passwd) |
cec204c6360c
plugin misc_account: fixed password verification
souliane <souliane@mailoo.org>
parents:
1653
diff
changeset
|
470 assert isinstance(verified, bool) |
cec204c6360c
plugin misc_account: fixed password verification
souliane <souliane@mailoo.org>
parents:
1653
diff
changeset
|
471 if verified: |
1041
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
472 if new_passwd1 == new_passwd2: |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
473 data = yield self.__change_password(new_passwd1, profile=profile) |
1041
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
474 defer.returnValue(data) |
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
475 else: |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
476 defer.returnValue( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
477 error_ui( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
478 D_("The values entered for the new password are not equal.") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
479 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
480 ) |
1031
e90125d07072
plugins misc_account, misc_smtp: update the plugins that deal with passwords
souliane <souliane@mailoo.org>
parents:
993
diff
changeset
|
481 defer.returnValue(error_ui()) |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
482 |
1031
e90125d07072
plugins misc_account, misc_smtp: update the plugins that deal with passwords
souliane <souliane@mailoo.org>
parents:
993
diff
changeset
|
483 defer.returnValue({}) |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
484 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
485 def __change_password(self, password, profile): |
1041
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
486 """Ask for a confirmation before changing the XMPP account and SàT profile passwords. |
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
487 |
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
488 @param password (str): the new password |
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
489 @param profile (str): %(doc_profile)s |
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
490 """ |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
491 session_id, __ = self._sessions.new_session( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
492 {"new_password": password}, profile=profile |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
493 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
494 form_ui = xml_tools.XMLUI( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
495 "form", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
496 title=D_("Change your password?"), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
497 submit_id=self.__change_password_id, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
498 session_id=session_id, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
499 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
500 form_ui.addText( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
501 D_( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
502 "Note for advanced users: this will actually change both your SàT profile password AND your XMPP account password." |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
503 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
504 ) |
1041
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
505 form_ui.addText(D_("Continue with changing the password?")) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
506 return {"xmlui": form_ui.toXml()} |
1041
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
507 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
508 def __change_password_cb(self, data, profile): |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
509 """Actually change the user XMPP account and SàT profile password |
1041
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
510 @param data (dict) |
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
511 @profile (str): %(doc_profile)s |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
512 """ |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
513 client = self.host.get_client(profile) |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
514 password = self._sessions.profile_get(data["session_id"], profile)["new_password"] |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
515 del self._sessions[data["session_id"]] |
1041
9095263011b6
plugin misc_accout: update relative to the introduction of profile password:
souliane <souliane@mailoo.org>
parents:
1040
diff
changeset
|
516 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
517 def password_changed(__): |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
518 d = self.host.memory.param_set( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
519 C.PROFILE_PASS_PATH[1], |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
520 password, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
521 C.PROFILE_PASS_PATH[0], |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
522 profile_key=profile, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
523 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
524 d.addCallback( |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
525 lambda __: self.host.memory.param_set( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
526 "Password", password, "Connection", profile_key=profile |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
527 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
528 ) |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
529 confirm_ui = xml_tools.XMLUI("popup", title=D_("Confirmation")) |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
530 confirm_ui.addText(D_("Your password has been changed.")) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
531 return defer.succeed({"xmlui": confirm_ui.toXml()}) |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
532 |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
533 def errback(failure): |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
534 error_ui = xml_tools.XMLUI("popup", title=D_("Error")) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
535 error_ui.addText( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
536 D_("Your password could not be changed: %s") % failure.getErrorMessage() |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
537 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
538 return defer.succeed({"xmlui": error_ui.toXml()}) |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
539 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
540 d = self.host.plugins["XEP-0077"].change_password(client, password) |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
541 d.addCallbacks(password_changed, errback) |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
542 return d |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
543 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
544 def __delete_account(self, profile): |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
545 """Ask for a confirmation before deleting the XMPP account and SàT profile |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
546 @param profile |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
547 """ |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
548 form_ui = xml_tools.XMLUI( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
549 "form", title=D_("Delete your account?"), submit_id=self.__delete_account_id |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
550 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
551 form_ui.addText( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
552 D_( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
553 "If you confirm this dialog, you will be disconnected and then your XMPP account AND your SàT profile will both be DELETED." |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
554 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
555 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
556 target = D_( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
557 "contact list, messages history, blog posts and comments" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
558 if "GROUPBLOG" in self.host.plugins |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
559 else D_("contact list and messages history") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
560 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
561 form_ui.addText( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
562 D_( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
563 "All your data stored on %(server)s, including your %(target)s will be erased." |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
564 ) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
565 % {"server": self.account_domain_new_get(), "target": target} |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
566 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
567 form_ui.addText( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
568 D_( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
569 "There is no other confirmation dialog, this is the very last one! Are you sure?" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
570 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
571 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
572 return {"xmlui": form_ui.toXml()} |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
573 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
574 def __delete_account_cb(self, data, profile): |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
575 """Actually delete the XMPP account and SàT profile |
2176
61128d260eef
plugin account: removed dependency to Prosody/prosodyctl and properly use in-band registration instead
Goffi <goffi@goffi.org>
parents:
2145
diff
changeset
|
576 |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
577 @param data |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
578 @param profile |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
579 """ |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
580 client = self.host.get_client(profile) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
581 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
582 def user_deleted(__): |
934
34dd9287dfe5
plugin account: bug fix profile deletion from the database + unsubscribe the contacts
souliane <souliane@mailoo.org>
parents:
895
diff
changeset
|
583 |
2176
61128d260eef
plugin account: removed dependency to Prosody/prosodyctl and properly use in-band registration instead
Goffi <goffi@goffi.org>
parents:
2145
diff
changeset
|
584 # FIXME: client should be disconnected at this point, so 2 next loop should be removed (to be confirmed) |
934
34dd9287dfe5
plugin account: bug fix profile deletion from the database + unsubscribe the contacts
souliane <souliane@mailoo.org>
parents:
895
diff
changeset
|
585 for jid_ in client.roster._jids: # empty roster |
34dd9287dfe5
plugin account: bug fix profile deletion from the database + unsubscribe the contacts
souliane <souliane@mailoo.org>
parents:
895
diff
changeset
|
586 client.presence.unsubscribe(jid_) |
34dd9287dfe5
plugin account: bug fix profile deletion from the database + unsubscribe the contacts
souliane <souliane@mailoo.org>
parents:
895
diff
changeset
|
587 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
588 for jid_ in self.host.memory.sub_waiting_get( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
589 profile |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
590 ): # delete waiting subscriptions |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
591 self.host.memory.del_waiting_sub(jid_) |
934
34dd9287dfe5
plugin account: bug fix profile deletion from the database + unsubscribe the contacts
souliane <souliane@mailoo.org>
parents:
895
diff
changeset
|
592 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
593 delete_profile = lambda: self.host.memory.profile_delete_async( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
594 profile, force=True |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
595 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
596 if "GROUPBLOG" in self.host.plugins: |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
597 d = self.host.plugins["GROUPBLOG"].deleteAllGroupBlogsAndComments( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
598 profile_key=profile |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
599 ) |
2765
378188abe941
misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents:
2624
diff
changeset
|
600 d.addCallback(lambda __: delete_profile()) |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
601 else: |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
602 delete_profile() |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
603 |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
604 return defer.succeed({}) |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
605 |
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
606 def errback(failure): |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
607 error_ui = xml_tools.XMLUI("popup", title=D_("Error")) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
608 error_ui.addText( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
609 D_("Your XMPP account could not be deleted: %s") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
610 % failure.getErrorMessage() |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
611 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
612 return defer.succeed({"xmlui": error_ui.toXml()}) |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
613 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
614 d = self.host.plugins["XEP-0077"].unregister(client, jid.JID(client.jid.host)) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
615 d.addCallbacks(user_deleted, errback) |
895
52ee240acc9c
plugin account: user can change his password or delete his XMPP account
souliane <souliane@mailoo.org>
parents:
870
diff
changeset
|
616 return d |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
617 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
618 def __delete_blog_posts(self, posts, comments, profile): |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
619 """Ask for a confirmation before deleting the blog posts |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
620 @param posts: delete all posts of the user (and their comments) |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
621 @param comments: delete all the comments of the user on other's posts |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
622 @param data |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
623 @param profile |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
624 """ |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
625 if posts: |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
626 if comments: # delete everything |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
627 form_ui = xml_tools.XMLUI( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
628 "form", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
629 title=D_("Delete all your (micro-)blog posts and comments?"), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
630 submit_id=self.__delete_posts_comments_id, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
631 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
632 form_ui.addText( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
633 D_( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
634 "If you confirm this dialog, all the (micro-)blog data you submitted will be erased." |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
635 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
636 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
637 form_ui.addText( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
638 D_( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
639 "These are the public and private posts and comments you sent to any group." |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
640 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
641 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
642 form_ui.addText( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
643 D_( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
644 "There is no other confirmation dialog, this is the very last one! Are you sure?" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
645 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
646 ) |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
647 else: # delete only the posts |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
648 form_ui = xml_tools.XMLUI( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
649 "form", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
650 title=D_("Delete all your (micro-)blog posts?"), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
651 submit_id=self.__delete_posts_id, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
652 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
653 form_ui.addText( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
654 D_( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
655 "If you confirm this dialog, all the public and private posts you sent to any group will be erased." |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
656 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
657 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
658 form_ui.addText( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
659 D_( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
660 "There is no other confirmation dialog, this is the very last one! Are you sure?" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
661 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
662 ) |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
663 elif comments: # delete only the comments |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
664 form_ui = xml_tools.XMLUI( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
665 "form", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
666 title=D_("Delete all your (micro-)blog comments?"), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
667 submit_id=self.__delete_comments_id, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
668 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
669 form_ui.addText( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
670 D_( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
671 "If you confirm this dialog, all the public and private comments you made on other people's posts will be erased." |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
672 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
673 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
674 form_ui.addText( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
675 D_( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
676 "There is no other confirmation dialog, this is the very last one! Are you sure?" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
677 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
678 ) |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
679 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
680 return {"xmlui": form_ui.toXml()} |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
681 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
682 def __delete_blog_posts_cb(self, posts, comments, data, profile): |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
683 """Actually delete the XMPP account and SàT profile |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
684 @param posts: delete all posts of the user (and their comments) |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
685 @param comments: delete all the comments of the user on other's posts |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
686 @param profile |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
687 """ |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
688 if posts: |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
689 if comments: |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
690 target = D_("blog posts and comments") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
691 d = self.host.plugins["GROUPBLOG"].deleteAllGroupBlogsAndComments( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
692 profile_key=profile |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
693 ) |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
694 else: |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
695 target = D_("blog posts") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
696 d = self.host.plugins["GROUPBLOG"].deleteAllGroupBlogs( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
697 profile_key=profile |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
698 ) |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
699 elif comments: |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
700 target = D_("comments") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
701 d = self.host.plugins["GROUPBLOG"].deleteAllGroupBlogsComments( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
702 profile_key=profile |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
703 ) |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
704 |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
705 def deleted(result): |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
706 ui = xml_tools.XMLUI("popup", title=D_("Deletion confirmation")) |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
707 # TODO: change the message when delete/retract notifications are done with XEP-0060 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
708 ui.addText(D_("Your %(target)s have been deleted.") % {"target": target}) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
709 ui.addText( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
710 D_( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
711 "Known issue of the demo version: you need to refresh the page to make the deleted posts actually disappear." |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
712 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
713 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
714 return defer.succeed({"xmlui": ui.toXml()}) |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
715 |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
716 def errback(failure): |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
717 error_ui = xml_tools.XMLUI("popup", title=D_("Error")) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
718 error_ui.addText( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
719 D_("Your %(target)s could not be deleted: %(message)s") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
720 % {"target": target, "message": failure.getErrorMessage()} |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
721 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
722 return defer.succeed({"xmlui": error_ui.toXml()}) |
938
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
723 |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
724 d.addCallbacks(deleted, errback) |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
725 return d |
fc7e0828b18e
plugin account, groupblog: user can erase all their microblogs at once
souliane <souliane@mailoo.org>
parents:
934
diff
changeset
|
726 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
727 def credentials_xmpp_connect(self, jid_s, password): |
1653
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
728 """Create and connect a new SàT profile using the given XMPP credentials. |
1696
9a7a27c44611
plugin account: fixed profile creation: session is started to set the connection parameters, then stopped
Goffi <goffi@goffi.org>
parents:
1691
diff
changeset
|
729 |
1653
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
730 Re-use given JID and XMPP password for the profile name and profile password. |
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
731 @param jid_s (unicode): JID |
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
732 @param password (unicode): XMPP password |
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
733 @return Deferred(bool) |
1696
9a7a27c44611
plugin account: fixed profile creation: session is started to set the connection parameters, then stopped
Goffi <goffi@goffi.org>
parents:
1691
diff
changeset
|
734 @raise exceptions.PasswordError, exceptions.ConflictError |
1653
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
735 """ |
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
736 try: # be sure that the profile doesn't exist yet |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
737 self.host.memory.get_profile_name(jid_s) |
1653
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
738 except exceptions.ProfileUnknownError: |
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
739 pass |
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
740 else: |
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
741 raise exceptions.ConflictError |
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
742 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
743 d = self.create_profile(password, jid_s, jid_s) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
744 d.addCallback( |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
745 lambda __: self.host.memory.get_profile_name(jid_s) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
746 ) # checks if the profile has been successfuly created |
4270
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
747 d.addCallback( |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
748 lambda profile: defer.ensureDeferred( |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
749 self.host.connect(profile, password, {}, 0) |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
750 ) |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
751 ) |
1653
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
752 |
1916
72837638f076
plugin misc_account: fixes two bugs introduced by revision 1907 (0b748ad46ede):
souliane <souliane@mailoo.org>
parents:
1907
diff
changeset
|
753 def connected(result): |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
754 self.send_emails(None, profile=jid_s) |
1916
72837638f076
plugin misc_account: fixes two bugs introduced by revision 1907 (0b748ad46ede):
souliane <souliane@mailoo.org>
parents:
1907
diff
changeset
|
755 return result |
72837638f076
plugin misc_account: fixes two bugs introduced by revision 1907 (0b748ad46ede):
souliane <souliane@mailoo.org>
parents:
1907
diff
changeset
|
756 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
757 def remove_profile( |
4270
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
758 failure, |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
759 ): # profile has been successfully created but the XMPP credentials are wrong! |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
760 log.debug( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
761 "Removing previously auto-created profile: %s" % failure.getErrorMessage() |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
762 ) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
763 self.host.memory.profile_delete_async(jid_s) |
1696
9a7a27c44611
plugin account: fixed profile creation: session is started to set the connection parameters, then stopped
Goffi <goffi@goffi.org>
parents:
1691
diff
changeset
|
764 raise failure |
1653
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
765 |
1907
0b748ad46ede
plugin misc account: separate profile creation and sending emails, so we can wait and send the emails at the right time (when we know that no error occured)
souliane <souliane@mailoo.org>
parents:
1901
diff
changeset
|
766 # FIXME: we don't catch the case where the JID host is not an XMPP server, and the user |
0b748ad46ede
plugin misc account: separate profile creation and sending emails, so we can wait and send the emails at the right time (when we know that no error occured)
souliane <souliane@mailoo.org>
parents:
1901
diff
changeset
|
767 # has to wait until the DBUS timeout ; as a consequence, emails are sent to the admins |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
768 # and the profile is not deleted. When the host exists, remove_profile is well called. |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3506
diff
changeset
|
769 d.addCallbacks(connected, remove_profile) |
1653
200efadcab76
plugin misc_account: add method asyncConnectWithXMPPCredentials
souliane <souliane@mailoo.org>
parents:
1433
diff
changeset
|
770 return d |