diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-04-20 20:40:24 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-04-21 23:57:47 +0300 |
| commit | c4683e6bd0e6ac7d94da082702b09fea37e531d9 (patch) | |
| tree | 5592ce4a969ecc484fbbcab76b8b37ccca7f4e23 /backend | |
| parent | test push for ci/cd (diff) | |
| download | lphub-c4683e6bd0e6ac7d94da082702b09fea37e531d9.tar.gz lphub-c4683e6bd0e6ac7d94da082702b09fea37e531d9.tar.bz2 lphub-c4683e6bd0e6ac7d94da082702b09fea37e531d9.zip | |
fix: empty country code on user creation (#36)
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/controllers/loginController.go | 4 | ||||
| -rw-r--r-- | backend/database/init.sql | 2 |
2 files changed, 5 insertions, 1 deletions
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) { | |||
| 50 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) | 50 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) |
| 51 | return | 51 | return |
| 52 | } | 52 | } |
| 53 | // Empty country code check | ||
| 54 | if user.LocCountryCode == "" { | ||
| 55 | user.LocCountryCode = "XX" | ||
| 56 | } | ||
| 53 | // Insert new user to database | 57 | // Insert new user to database |
| 54 | database.DB.Exec(`INSERT INTO users (steam_id, username, avatar_link, country_code) | 58 | database.DB.Exec(`INSERT INTO users (steam_id, username, avatar_link, country_code) |
| 55 | VALUES ($1, $2, $3, $4)`, steamID, user.PersonaName, user.AvatarFull, user.LocCountryCode) | 59 | 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 ( | |||
| 12 | steam_id TEXT, | 12 | steam_id TEXT, |
| 13 | username TEXT NOT NULL, | 13 | username TEXT NOT NULL, |
| 14 | avatar_link TEXT NOT NULL, | 14 | avatar_link TEXT NOT NULL, |
| 15 | country_code CHAR(2) NOT NULL DEFAULT 'XX', | 15 | country_code CHAR(2) NOT NULL, |
| 16 | created_at TIMESTAMP NOT NULL DEFAULT now(), | 16 | created_at TIMESTAMP NOT NULL DEFAULT now(), |
| 17 | updated_at TIMESTAMP NOT NULL DEFAULT now(), | 17 | updated_at TIMESTAMP NOT NULL DEFAULT now(), |
| 18 | PRIMARY KEY (steam_id) | 18 | PRIMARY KEY (steam_id) |