From c4683e6bd0e6ac7d94da082702b09fea37e531d9 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Thu, 20 Apr 2023 20:40:24 +0300 Subject: fix: empty country code on user creation (#36) --- backend/controllers/loginController.go | 4 ++++ backend/database/init.sql | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'backend') diff --git a/backend/controllers/loginController.go b/backend/controllers/loginController.go index 84ef22f..3e59211 100644 --- a/backend/controllers/loginController.go +++ b/backend/controllers/loginController.go @@ -50,6 +50,10 @@ func Login(c *gin.Context) { c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) return } + // Empty country code check + if user.LocCountryCode == "" { + user.LocCountryCode = "XX" + } // Insert new user to database database.DB.Exec(`INSERT INTO users (steam_id, username, avatar_link, country_code) VALUES ($1, $2, $3, $4)`, steamID, user.PersonaName, user.AvatarFull, user.LocCountryCode) diff --git a/backend/database/init.sql b/backend/database/init.sql index 1b35c02..7e225f0 100644 --- a/backend/database/init.sql +++ b/backend/database/init.sql @@ -12,7 +12,7 @@ CREATE TABLE users ( steam_id TEXT, username TEXT NOT NULL, avatar_link TEXT NOT NULL, - country_code CHAR(2) NOT NULL DEFAULT 'XX', + country_code CHAR(2) NOT NULL, created_at TIMESTAMP NOT NULL DEFAULT now(), updated_at TIMESTAMP NOT NULL DEFAULT now(), PRIMARY KEY (steam_id) -- cgit v1.2.3