diff options
Diffstat (limited to 'signup.go')
| -rw-r--r-- | signup.go | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -6,7 +6,7 @@ import _ "github.com/go-sql-driver/mysql" import "golang.org/x/crypto/bcrypt" import "net/http" -import "fmt" +//import "fmt" import "os/exec" var db *sql.DB @@ -30,25 +30,30 @@ func signupPage(res http.ResponseWriter, req *http.Request) { hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) if err != nil { http.Error(res, "Server Error creating Password. Unable to create account! You Fool...", 500) + Log("ERROR 500") return } newuuid, uiderr := exec.Command("uuidgen").Output() if uiderr != nil{ http.Error(res, "Server Error creating UUID. Unable to create account! You Fool...", 500) + Log("ERROR 500") return } _, err = db.Exec("INSERT INTO players(username, password, uuid) VALUES(?, ?, ?)", username, hashedPassword, newuuid) if err != nil { http.Error(res, "Server Error Inserting User. Unable to create account! You Fool...", 500) - fmt.Println("Error adding User",username) + Log("ERROR adding user"+username) + //fmt.Println("Error adding User",username) return } res.Write([]byte("User Created Successfully!")) - fmt.Println("Successfully Created User",username,newuuid) + Log("Successfully Created User"+username+string(newuuid)) + //fmt.Println("Successfully Created User",username,newuuid) return case err != nil: http.Error(res, "Server Error! Something fucked up", 500) + Log("ERROR Something fucked up") return default: http.Redirect(res, req, "/", 301) @@ -72,19 +77,22 @@ func loginPage(res http.ResponseWriter, req *http.Request) { if err != nil { http.Redirect(res, req, "/login", 301) - fmt.Println("Failed Login atempt by",username) + Log("Failed Login atempt by "+username) + //fmt.Println("Failed Login atempt by",username) return } err = bcrypt.CompareHashAndPassword([]byte(databasePassword), []byte(password)) if err != nil { http.Redirect(res, req, "/login", 301) - fmt.Println(username," used wrong Password ",password) + Log(username+" used wrong Password "+password) + //fmt.Println(username," used wrong Password ",password) return } res.Write([]byte("Hello "+ databaseUsername + "! Your UUID is "+ databaseUUID)) - fmt.Println("Successful Login by",username) + Log("Successful Login by "+username) + //fmt.Println("Successful Login by",username) } func homePage(res http.ResponseWriter, req *http.Request) { |
