diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-07-09 11:04:59 +0300 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-07-09 11:04:59 +0300 |
| commit | f8afb8b5efd769007d333235786b3969663ce159 (patch) | |
| tree | b1d00eafed53130286cc0ab678a7cd01f83b7930 | |
| parent | cdacb12941c702611c7015cb3ee67bdb27d0eea2 (diff) | |
| download | ctfc-f8afb8b5efd769007d333235786b3969663ce159.tar ctfc-f8afb8b5efd769007d333235786b3969663ce159.tar.gz ctfc-f8afb8b5efd769007d333235786b3969663ce159.zip | |
Implemented user logging out
| -rw-r--r-- | go-src/user.go | 5 | ||||
| -rw-r--r-- | go-src/windows.go | 24 |
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) { |
