|
1
|
|
|
# |
|
2
|
|
|
# Copyright 2001 - 2018 Ludek Smid [http://www.ospace.net/] |
|
3
|
|
|
# |
|
4
|
|
|
# This file is part of Outer Space. |
|
5
|
|
|
# |
|
6
|
|
|
# Outer Space is free software; you can redistribute it and/or modify |
|
7
|
|
|
# it under the terms of the GNU General Public License as published by |
|
8
|
|
|
# the Free Software Foundation; either version 2 of the License, or |
|
9
|
|
|
# (at your option) any later version. |
|
10
|
|
|
# |
|
11
|
|
|
# Outer Space is distributed in the hope that it will be useful, |
|
12
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14
|
|
|
# GNU General Public License for more details. |
|
15
|
|
|
# |
|
16
|
|
|
# You should have received a copy of the GNU General Public License |
|
17
|
|
|
# along with Outer Space; if not, write to the Free Software |
|
18
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
19
|
|
|
# |
|
20
|
|
|
|
|
21
|
|
|
import pygameui as ui |
|
22
|
|
|
from osci import client, gdata, res |
|
23
|
|
|
from ige import SecurityException |
|
24
|
|
|
|
|
25
|
|
|
class ChangePasswordDlg: |
|
26
|
|
|
|
|
27
|
|
|
def __init__(self, app): |
|
28
|
|
|
self.app = app |
|
29
|
|
|
self.createUI() |
|
30
|
|
|
|
|
31
|
|
|
def display(self, caller = None, message = None): |
|
32
|
|
|
self.caller = caller |
|
33
|
|
|
self.win.vOld.text = "" |
|
34
|
|
|
self.win.vNew.text = "" |
|
35
|
|
|
self.win.vConfirm.text = "" |
|
36
|
|
|
self.win.show() |
|
37
|
|
|
|
|
38
|
|
|
def hide(self): |
|
39
|
|
|
self.win.hide() |
|
40
|
|
|
|
|
41
|
|
|
def onChange(self, widget, action, data): |
|
42
|
|
|
oldPassword = self.win.vOld.text |
|
43
|
|
|
newPassword = self.win.vNew.text |
|
44
|
|
|
confirmPassword = self.win.vConfirm.text |
|
45
|
|
|
if newPassword != confirmPassword: |
|
46
|
|
|
self.win.vMessage.text = _("Passwords do not match.") |
|
47
|
|
|
self.win.vNew.text = "" |
|
48
|
|
|
self.win.vConfirm.text = "" |
|
49
|
|
|
return |
|
50
|
|
|
self.win.hide() |
|
51
|
|
|
try: |
|
52
|
|
|
client.cmdProxy.changePassword(oldPassword, newPassword) |
|
53
|
|
|
except SecurityException, e: |
|
54
|
|
|
# failed |
|
55
|
|
|
self.win.vMessage.text = _(e.args[0]) |
|
56
|
|
|
self.win.show() |
|
57
|
|
|
return |
|
58
|
|
|
if self.caller: |
|
59
|
|
|
self.caller.display(message = _("The password has been changed.")) |
|
60
|
|
|
|
|
61
|
|
|
def onCancel(self, widget, action, data): |
|
62
|
|
|
self.win.hide() |
|
63
|
|
|
if self.caller: |
|
64
|
|
|
self.caller.display() |
|
65
|
|
|
|
|
66
|
|
|
def createUI(self): |
|
67
|
|
|
w, h = gdata.scrnSize |
|
68
|
|
|
self.win = ui.Window(self.app, |
|
69
|
|
|
modal = 1, |
|
70
|
|
|
movable = 0, |
|
71
|
|
|
title = _('Change password'), |
|
72
|
|
|
rect = ui.Rect((w - 324) / 2, (h - 104) / 2, 324, 104), |
|
73
|
|
|
layoutManager = ui.SimpleGridLM(), |
|
74
|
|
|
tabChange = True |
|
75
|
|
|
) |
|
76
|
|
|
self.win.subscribeAction('*', self) |
|
77
|
|
|
ui.Label(self.win, |
|
78
|
|
|
text = _('Old password'), |
|
79
|
|
|
align = ui.ALIGN_E, |
|
80
|
|
|
layout = (0, 0, 6, 1) |
|
81
|
|
|
) |
|
82
|
|
|
ui.Entry(self.win, id = 'vOld', |
|
83
|
|
|
align = ui.ALIGN_W, |
|
84
|
|
|
showChar = '*', |
|
85
|
|
|
layout = (6, 0, 10, 1), |
|
86
|
|
|
orderNo = 1 |
|
87
|
|
|
) |
|
88
|
|
|
ui.Label(self.win, |
|
89
|
|
|
text = _('New password'), |
|
90
|
|
|
align = ui.ALIGN_E, |
|
91
|
|
|
layout = (0, 1, 6, 1), |
|
92
|
|
|
) |
|
93
|
|
|
ui.Entry(self.win, id = 'vNew', |
|
94
|
|
|
align = ui.ALIGN_W, |
|
95
|
|
|
showChar = '*', |
|
96
|
|
|
layout = (6, 1, 10, 1), |
|
97
|
|
|
orderNo = 2 |
|
98
|
|
|
) |
|
99
|
|
|
ui.Label(self.win, |
|
100
|
|
|
align = ui.ALIGN_E, |
|
101
|
|
|
text = _('Confirm'), |
|
102
|
|
|
layout = (0, 2, 6, 1), |
|
103
|
|
|
) |
|
104
|
|
|
ui.Entry(self.win, id = 'vConfirm', |
|
105
|
|
|
align = ui.ALIGN_W, |
|
106
|
|
|
layout = (6, 2, 10, 1), |
|
107
|
|
|
showChar = "*", |
|
108
|
|
|
orderNo = 3 |
|
109
|
|
|
) |
|
110
|
|
|
ui.Title(self.win, layout = (0, 3, 8, 1), id = 'vMessage', align = ui.ALIGN_W) |
|
111
|
|
|
ui.TitleButton(self.win, layout = (8, 3, 4, 1), text = _('Cancel'), action = 'onCancel') |
|
112
|
|
|
ui.TitleButton(self.win, layout = (12, 3, 4, 1), text = _('Apply'), action = 'onChange') |
|
113
|
|
|
|