aboutsummaryrefslogtreecommitdiff
path: root/go-src/windows.go
diff options
context:
space:
mode:
Diffstat (limited to 'go-src/windows.go')
-rw-r--r--go-src/windows.go39
1 files changed, 12 insertions, 27 deletions
diff --git a/go-src/windows.go b/go-src/windows.go
index 31c2fb0..5463cd2 100644
--- a/go-src/windows.go
+++ b/go-src/windows.go
@@ -1,7 +1,6 @@
package ctfc
import (
- "strconv"
"strings"
"gitlab.com/Syndamia/ctfc/go-src/csi"
@@ -254,7 +253,6 @@ func directMessagesWindow(values ...string) {
defer nextWindow()
}
lastLine = -2
-
}
func directMessageWindow(values ...string) {
@@ -341,31 +339,18 @@ func accountWindow(values ...string) {
)
if nextWindow == nil {
- userProp, _ := strconv.Atoi(input)
- inputs, updateSuccessful := []formInput{{currentPasswordInName, inputBackSpec, nil}}, false
-
- switch UserProp(userProp) {
- case passwordProp:
- values := formWindow(editPasswordNavTitle, accountWindow,
- append(inputs, formInput{newPasswordInName, passwordSpec, stringValidPassword}),
- )
- updateSuccessful = loggedInUser.UpdatePassword(values[0], values[1])
- case nameProp:
- values := formWindow(editNameNavTitle, accountWindow,
- append(inputs, formInput{newNameInName, nameSpec, stringValidName}),
- )
- updateSuccessful = loggedInUser.UpdateName(values[0], values[1])
- loggedInUser.Name = utils.If(updateSuccessful).String(values[1], loggedInUser.Name)
- default:
- defer showError(invalidCommand, accountWindow)
- return
- }
-
- if !updateSuccessful {
- defer showError(invalidArgument, accountWindow)
- } else {
- defer accountWindow()
- }
+ defer validatedMultiForm(input, accountWindow,
+ multiFormProp{int(passwordProp), editPasswordNavTitle,
+ formInput{newPasswordInName, passwordSpec, stringValidPassword},
+ func(values []string) bool { return loggedInUser.UpdatePassword(values[0], values[1]) },
+ nil,
+ },
+ multiFormProp{int(nameProp), editNameNavTitle,
+ formInput{newNameInName, nameSpec, stringValidName},
+ func(values []string) bool { return loggedInUser.UpdateName(values[0], values[1]) },
+ func(values []string) { loggedInUser.Name = values[1] },
+ },
+ )
} else {
defer nextWindow()
}