-
Notifications
You must be signed in to change notification settings - Fork 5
/
chgpass.go
43 lines (36 loc) · 1.09 KB
/
chgpass.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"github.com/rivo/tview"
)
func showChangePasswordWindow() {
const (
windowName = "changePassword"
windowWidth = 40
windowHeight = 10
windowTitle = S_WINDOW_CHANGEPASS_TITLE
)
form := tview.NewForm()
form.SetTitle(windowTitle)
form.SetBorder(true)
passwordField := tview.NewInputField().SetLabel(S_WINDOW_CHANGEPASS_LABEL_PASSWORD).
SetFieldWidth(0).
SetMaskCharacter('*')
passwordFieldConfirm := tview.NewInputField().SetLabel(S_WINDOW_CHANGEPASS_LABEL_CONFIRM).
SetFieldWidth(0).
SetMaskCharacter('*')
form.AddButton(S_WINDOW_CHANGEPASS_BUTTON_OK, func() {
if passwordField.GetText() != passwordFieldConfirm.GetText() {
showFailWindow(S_MSG_PASSWORD_MISMATCH)
} else {
masterKey.changePassword([]byte(passwordField.GetText()))
masterKey.store(masterKey.path)
showSuccessWindow(S_MSG_PASSWORD_CHANGED, func() {
layoutRoot.RemovePage(windowName)
})
}
})
form.AddFormItem(passwordField)
form.AddFormItem(passwordFieldConfirm)
form.SetFocus(0)
layoutRoot.AddPage(windowName, popup(windowWidth, windowHeight, form), true, true)
}