about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/http.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/http.go b/src/http.go
index a9b4240..5ed4957 100644
--- a/src/http.go
+++ b/src/http.go
@@ -4,6 +4,7 @@ import (
 	"flag"
 	"fmt"
 	"io/ioutil"
+	"log"
 	"net/http"
 	"strings"
 
@@ -50,7 +51,8 @@ func registerPostHandler(w http.ResponseWriter, r *http.Request) {
 
 	// test if the username has already been chosen
 	if !isUniq(username) {
-		w.Write([]byte("Username has already been taken."))
+		log.Println("redirecting to usernameTaken")
+		usernameTakenGetHandler(w, r)
 		return
 	}
 
@@ -59,11 +61,17 @@ func registerPostHandler(w http.ResponseWriter, r *http.Request) {
 
 	// generate a new accesscode
 	accesscode := newAccessCode()
+	log.Printf("Generated a new AccessCode for user %s: %s", username, accesscode)
 
 	// redirect the user to the front page
 	http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
 }
 
+func usernameTakenGetHandler(w http.ResponseWriter, r *http.Request) {
+	log.Println("[usernameTaken]")
+	readFileToReponse(w, "/usernameTaken.html")
+}
+
 func isUniq(username string) bool {
 	for _, user := range usernames {
 		if username == user {