Exemple #1
0
// Create a new user record
func createUser(users *db.Col, user UserData) (int, string) {

	// Do some trivial checking on the email and password before processing
	if !strings.Contains(user.Email, "@") || !strings.Contains(user.Email, ".") {
		log.Println(user.Email, "has no @ or .")
		return 403, "Invalid Email Address"
	}
	if len(user.Password) < 1 {
		log.Println("Empty Password")
		return 403, "Empty Password"
	}

	_, err := users.Insert(map[string]interface{}{
		"Email":    user.Email,
		"Password": user.Password,
		"Valid":    false,
		"LoggedIn": false,
		"Location": user.Location,
		"Credit":   0,
		"Scale":    user.Scale,
		"Armies":   user.Armies,
		"GameTime": user.GameTime,
	})
	if err != nil {
		panic(err)
	}

	log.Println("Registering User:"******"Added User"
}