aboutsummaryrefslogtreecommitdiff
path: root/go-src
diff options
context:
space:
mode:
Diffstat (limited to 'go-src')
-rw-r--r--go-src/user.go5
-rw-r--r--go-src/windows.go24
2 files changed, 28 insertions, 1 deletions
diff --git a/go-src/user.go b/go-src/user.go
index 13b100d..0cbe5b0 100644
--- a/go-src/user.go
+++ b/go-src/user.go
@@ -29,6 +29,11 @@ func logInUser(username string, password string) bool {
return false
}
+func logoutUser() {
+ loggedInUser.Username = ""
+ loggedInUser.Name = ""
+}
+
func getUser(username string) User {
f, _ := os.ReadFile(folderPaths.FileAtUsersFolder(username))
values := bytes.Split(f, []byte("\n"))
diff --git a/go-src/windows.go b/go-src/windows.go
index 94ac60b..d442287 100644
--- a/go-src/windows.go
+++ b/go-src/windows.go
@@ -74,6 +74,24 @@ func chatsWindow(values ...string) {
}
}
+func logoutWindow(...string) {
+ clearScreen()
+
+ ui.NormalBox(true, "Are you sure you want to Log out of "+loggedInUser.Username+"?")
+ ui.EmptyLine()
+
+ input := ui.InputField("[Y/N]")
+
+ if strings.ToLower(input) == "y" {
+ logoutUser()
+ defer StartupWindow()
+ } else {
+ defer chatsWindow()
+ }
+}
+
+/* Form */
+
type formInput struct {
name string
specification string
@@ -108,6 +126,8 @@ func formWindow(boxTitle string, formInputs []formInput, currentValues ...string
return
}
+/* Input actions */
+
type inputAction struct {
value string
execute func(...string)
@@ -120,7 +140,7 @@ func handleInputActions(input string, handleNav bool, ia ...inputAction) bool {
inputAction{"C", chatsWindow, nil},
inputAction{"D", chatsWindow, nil},
inputAction{"A", chatsWindow, nil},
- inputAction{"L", chatsWindow, nil},
+ inputAction{"L", logoutWindow, nil},
)
}
for _, v := range ia {
@@ -132,6 +152,8 @@ func handleInputActions(input string, handleNav bool, ia ...inputAction) bool {
return false
}
+/* Errors and Clear */
+
var clearNext = true
func showError(message string, callback func(...string), callbackData ...string) {