diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-02 11:09:42 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-02 11:09:42 +0300 |
| commit | 69c5423f7954b641109166e03ad0ab174b3d55c6 (patch) | |
| tree | c53539e4b0ee17620422de3761dba70277c417c9 /backend/handlers/login.go | |
| parent | docs: added privacy policy (diff) | |
| download | lphub-69c5423f7954b641109166e03ad0ab174b3d55c6.tar.gz lphub-69c5423f7954b641109166e03ad0ab174b3d55c6.tar.bz2 lphub-69c5423f7954b641109166e03ad0ab174b3d55c6.zip | |
feat: testing logging system (#55)
Former-commit-id: d8c5fda30ab08b42218aead1febdf83200948763
Diffstat (limited to 'backend/handlers/login.go')
| -rw-r--r-- | backend/handlers/login.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/backend/handlers/login.go b/backend/handlers/login.go index 4b151c2..80f697e 100644 --- a/backend/handlers/login.go +++ b/backend/handlers/login.go | |||
| @@ -38,6 +38,7 @@ func Login(c *gin.Context) { | |||
| 38 | default: | 38 | default: |
| 39 | steamID, err := openID.ValidateAndGetId() | 39 | steamID, err := openID.ValidateAndGetId() |
| 40 | if err != nil { | 40 | if err != nil { |
| 41 | CreateLog(steamID, LogTypeLogin, LogDescriptionLoginFailValidate) | ||
| 41 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) | 42 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) |
| 42 | return | 43 | return |
| 43 | } | 44 | } |
| @@ -48,6 +49,7 @@ func Login(c *gin.Context) { | |||
| 48 | if checkSteamID == 0 { | 49 | if checkSteamID == 0 { |
| 49 | user, err := GetPlayerSummaries(steamID, os.Getenv("API_KEY")) | 50 | user, err := GetPlayerSummaries(steamID, os.Getenv("API_KEY")) |
| 50 | if err != nil { | 51 | if err != nil { |
| 52 | CreateLog(steamID, LogTypeLogin, LogDescriptionLoginFailSummary) | ||
| 51 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) | 53 | c.JSON(http.StatusBadRequest, models.ErrorResponse(err.Error())) |
| 52 | return | 54 | return |
| 53 | } | 55 | } |
| @@ -77,10 +79,12 @@ func Login(c *gin.Context) { | |||
| 77 | // Sign and get the complete encoded token as a string using the secret | 79 | // Sign and get the complete encoded token as a string using the secret |
| 78 | tokenString, err := token.SignedString([]byte(os.Getenv("SECRET_KEY"))) | 80 | tokenString, err := token.SignedString([]byte(os.Getenv("SECRET_KEY"))) |
| 79 | if err != nil { | 81 | if err != nil { |
| 82 | CreateLog(steamID, LogTypeLogin, LogDescriptionLoginFailToken) | ||
| 80 | c.JSON(http.StatusBadRequest, models.ErrorResponse("Failed to generate token.")) | 83 | c.JSON(http.StatusBadRequest, models.ErrorResponse("Failed to generate token.")) |
| 81 | return | 84 | return |
| 82 | } | 85 | } |
| 83 | c.SetCookie("token", tokenString, 3600*24*30, "/", "", true, true) | 86 | c.SetCookie("token", tokenString, 3600*24*30, "/", "", true, true) |
| 87 | CreateLog(steamID, LogTypeLogin, LogDescriptionLoginSuccess) | ||
| 84 | c.Redirect(http.StatusTemporaryRedirect, "/") | 88 | c.Redirect(http.StatusTemporaryRedirect, "/") |
| 85 | // c.JSON(http.StatusOK, models.Response{ | 89 | // c.JSON(http.StatusOK, models.Response{ |
| 86 | // Success: true, | 90 | // Success: true, |