diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-27 22:52:19 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-27 22:52:19 +0300 |
| commit | 1ef4498dadd8cdf7b60f4f256697d9329c9e9deb (patch) | |
| tree | d70a1dd5bfff99a4add4aaa47bc584b3c2305131 /backend/handlers/login.go | |
| parent | feat: detailed logging, db changes (#55) (diff) | |
| download | lphub-1ef4498dadd8cdf7b60f4f256697d9329c9e9deb.tar.gz lphub-1ef4498dadd8cdf7b60f4f256697d9329c9e9deb.tar.bz2 lphub-1ef4498dadd8cdf7b60f4f256697d9329c9e9deb.zip | |
feat: revise logging in other handlers (#55)
Former-commit-id: ef5d934328d4389405cd51c08c2738093353a5cd
Diffstat (limited to 'backend/handlers/login.go')
| -rw-r--r-- | backend/handlers/login.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/backend/handlers/login.go b/backend/handlers/login.go index b0f5ef6..1a74166 100644 --- a/backend/handlers/login.go +++ b/backend/handlers/login.go | |||
| @@ -37,7 +37,7 @@ func Login(c *gin.Context) { | |||
| 37 | default: | 37 | default: |
| 38 | steamID, err := openID.ValidateAndGetID() | 38 | steamID, err := openID.ValidateAndGetID() |
| 39 | if err != nil { | 39 | if err != nil { |
| 40 | CreateLog(steamID, LogTypeUser, LogDescriptionUserLoginFailValidate) | 40 | CreateLog(steamID, LogTypeUser, LogDescriptionUserLoginFailValidate, err.Error()) |
| 41 | c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) | 41 | c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) |
| 42 | return | 42 | return |
| 43 | } | 43 | } |
| @@ -48,7 +48,7 @@ func Login(c *gin.Context) { | |||
| 48 | if checkSteamID == 0 { | 48 | if checkSteamID == 0 { |
| 49 | user, err := GetPlayerSummaries(steamID, os.Getenv("API_KEY")) | 49 | user, err := GetPlayerSummaries(steamID, os.Getenv("API_KEY")) |
| 50 | if err != nil { | 50 | if err != nil { |
| 51 | CreateLog(steamID, LogTypeUser, LogDescriptionUserLoginFailSummary) | 51 | CreateLog(steamID, LogTypeUser, LogDescriptionUserLoginFailSummary, err.Error()) |
| 52 | c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) | 52 | c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) |
| 53 | return | 53 | return |
| 54 | } | 54 | } |
| @@ -78,12 +78,12 @@ func Login(c *gin.Context) { | |||
| 78 | // Sign and get the complete encoded token as a string using the secret | 78 | // Sign and get the complete encoded token as a string using the secret |
| 79 | tokenString, err := token.SignedString([]byte(os.Getenv("SECRET_KEY"))) | 79 | tokenString, err := token.SignedString([]byte(os.Getenv("SECRET_KEY"))) |
| 80 | if err != nil { | 80 | if err != nil { |
| 81 | CreateLog(steamID, LogTypeUser, LogDescriptionUserLoginFailToken) | 81 | CreateLog(steamID, LogTypeUser, LogDescriptionUserLoginFailToken, err.Error()) |
| 82 | c.JSON(http.StatusOK, models.ErrorResponse("Failed to generate token.")) | 82 | c.JSON(http.StatusOK, models.ErrorResponse("Failed to generate token.")) |
| 83 | return | 83 | return |
| 84 | } | 84 | } |
| 85 | c.SetCookie("token", tokenString, 3600*24*30, "/", "", true, true) | 85 | c.SetCookie("token", tokenString, 3600*24*30, "/", "", true, true) |
| 86 | CreateLog(steamID, LogTypeUser, LogDescriptionUserLoginSuccess) | 86 | // CreateLog(steamID, LogTypeUser, LogDescriptionUserLoginSuccess) |
| 87 | c.Redirect(http.StatusTemporaryRedirect, "/") | 87 | c.Redirect(http.StatusTemporaryRedirect, "/") |
| 88 | // c.JSON(http.StatusOK, models.Response{ | 88 | // c.JSON(http.StatusOK, models.Response{ |
| 89 | // Success: true, | 89 | // Success: true, |