equal
deleted
inserted
replaced
12 |
12 |
13 from VirtualMailManager.errors import VMMError |
13 from VirtualMailManager.errors import VMMError |
14 from VirtualMailManager.handler import Handler |
14 from VirtualMailManager.handler import Handler |
15 from VirtualMailManager.cli import read_pass |
15 from VirtualMailManager.cli import read_pass |
16 from VirtualMailManager.cli.config import CliConfig as Cfg |
16 from VirtualMailManager.cli.config import CliConfig as Cfg |
17 from VirtualMailManager.constants import INVALID_SECTION |
17 from VirtualMailManager.constants import ACCOUNT_EXISTS, INVALID_SECTION |
18 |
18 |
19 _ = lambda msg: msg |
19 _ = lambda msg: msg |
20 |
20 |
21 |
21 |
22 class CliHandler(Handler): |
22 class CliHandler(Handler): |
66 else: |
66 else: |
67 raise VMMError(_(u'Invalid section: ā%sā') % section, |
67 raise VMMError(_(u'Invalid section: ā%sā') % section, |
68 INVALID_SECTION) |
68 INVALID_SECTION) |
69 |
69 |
70 def user_add(self, emailaddress, password=None): |
70 def user_add(self, emailaddress, password=None): |
71 """Prefix the parent user_add() with the interactive password |
71 """Override the parent user_add() - add the interactive password |
72 dialog.""" |
72 dialog.""" |
|
73 acc = self._get_account(emailaddress) |
|
74 if acc: |
|
75 raise VMMError(_(u"The account '%s' already exists.") % |
|
76 acc.address, ACCOUNT_EXISTS) |
73 if password is None: |
77 if password is None: |
74 password = read_pass() |
78 password = read_pass() |
75 super(CliHandler, self).user_add(emailaddress, password) |
79 acc.set_password(password) |
|
80 acc.save() |
|
81 self._make_account_dirs(acc) |
76 |
82 |
77 def user_password(self, emailaddress, password=None): |
83 def user_password(self, emailaddress, password=None): |
78 """Prefix the parent user_password() with the interactive password |
84 """Prefix the parent user_password() with the interactive password |
79 dialog.""" |
85 dialog.""" |
80 if password is None: |
86 if password is None: |