func (c *RegistrationsController) Create(w http.ResponseWriter, r *http.Request) {
	decoder := json.NewDecoder(r.Body)
	var p RegistrationParams
	err := decoder.Decode(&p)
	if err != nil {
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}

	account := models.Account{
		CreatedAt: time.Now(),
		Email:     p.Email,
	}

	account.GenSubdomain()

	if err = account.GenEncryptedPassword(p.Password); err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	err = models.Insert(&account)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	tokenString, err := account.GenJwt()
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(http.StatusCreated)
	fmt.Fprint(w, Response{"token": tokenString})
}
func TestRecordingImageRequests(t *testing.T) {
	models.InitDb("postgres://localhost/firesize_test?sslmode=disable")
	defer models.Dbm.TruncateTables()

	router := mux.NewRouter()
	router.SkipClean(true)
	new(ImagesController).Init(router)

	recorder := httptest.NewRecorder()

	account := models.Account{
		CreatedAt: time.Now(),
		Email:     "*****@*****.**",
		Subdomain: "testing",
	}

	err := models.Insert(&account)
	if err != nil {
		t.Fatal(err.Error())
	}

	request, err := http.NewRequest("GET", "http://testing.firesize.dev/500x300/g_center/http://placekitten.com/g/800/600", nil)
	if err != nil {
		t.Fatal("Failed to GET http://testing.firesize.dev/500x300/g_center/http://placekitten.com/g/800/600")
	}

	router.ServeHTTP(recorder, request)

	if recorder.Code != http.StatusOK {
		t.Fatal("Incorrect response code returned. Expected: ", http.StatusOK, ", Received: ", recorder.Code)
	}

	count := models.FindImageRequestCountForAccount(&account)
	if count != 1 {
		t.Fatal("Incorrect image request count. Expected: 1, Received: ", count)
	}
}