Trim space from createuser input

This commit is contained in:
Magnus Åhall 2024-01-26 08:00:51 +01:00
parent 3b778226c8
commit 772c54f6fe

4
pkg.go
View File

@ -49,6 +49,7 @@ import (
"net/http" "net/http"
"os" "os"
"regexp" "regexp"
"strings"
) )
const VERSION = "v0.1.0" const VERSION = "v0.1.0"
@ -239,12 +240,15 @@ func (service *Service) CreateUserPrompt() { // {{{
fmt.Printf("Username: ") fmt.Printf("Username: ")
username, _ = reader.ReadString('\n') username, _ = reader.ReadString('\n')
username = strings.TrimSpace(username)
fmt.Printf("Name: ") fmt.Printf("Name: ")
name, _ = reader.ReadString('\n') name, _ = reader.ReadString('\n')
name = strings.TrimSpace(name)
fmt.Printf("Password: ") fmt.Printf("Password: ")
password, _ = reader.ReadString('\n') password, _ = reader.ReadString('\n')
password = strings.TrimSpace(password)
err = service.CreateUser(username, password, name) err = service.CreateUser(username, password, name)
if err != nil { if err != nil {