aboutsummaryrefslogtreecommitdiff
path: root/go-src/windows.go
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-07-23 10:19:42 +0300
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-07-23 10:19:42 +0300
commit803099c73e6b1f4a5fb84c204ebb071ee1e350b8 (patch)
tree4720a40e84fe828de8cbe48f6e4518e455311786 /go-src/windows.go
parent0b281b813a9ab00d7c69eb140ab5ac2952987316 (diff)
downloadctfc-803099c73e6b1f4a5fb84c204ebb071ee1e350b8.tar
ctfc-803099c73e6b1f4a5fb84c204ebb071ee1e350b8.tar.gz
ctfc-803099c73e6b1f4a5fb84c204ebb071ee1e350b8.zip
Reworked user functions into methods, properly implemented account updating
Diffstat (limited to 'go-src/windows.go')
-rw-r--r--go-src/windows.go44
1 files changed, 20 insertions, 24 deletions
diff --git a/go-src/windows.go b/go-src/windows.go
index b88c224..7401536 100644
--- a/go-src/windows.go
+++ b/go-src/windows.go
@@ -237,34 +237,30 @@ func accountWindow(...string) {
nextWindow := handleInputActions(input, true)
if nextWindow == nil {
- editI, _ := strconv.Atoi(input)
- switch editI {
- case 1:
- pass := formWindow("Editing", accountWindow,
- []formInput{
- {"Current password", inputBackSpec, nil},
- {"New password", "", stringValidPassword},
- },
+ 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}),
)
- if !updatePassword(pass[0], pass[1]) {
- defer showError(invalidArgument, accountWindow)
- } else {
- defer accountWindow()
- }
- case 2:
- newName := formWindow("Editing", accountWindow,
- []formInput{
- {"Current password", inputBackSpec, nil},
- {"New name", "", stringValidName},
- },
+ updateSuccessful = loggedInUser.UpdatePassword(values[0], values[1])
+ case nameProp:
+ values := formWindow(editNameNavTitle, accountWindow,
+ append(inputs, formInput{newNameInName, nameSpec, stringValidName}),
)
- if !updateName(newName[0], newName[1]) {
- defer showError(invalidArgument, accountWindow)
- } else {
- defer accountWindow()
- }
+ 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()
}
} else {
defer nextWindow()