diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-24 01:56:28 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-24 01:56:28 +0300 |
| commit | ae4cec37e90ecc332cb1e7985e8a471c8efe385b (patch) | |
| tree | 3ad4ab78ef174e4f60b0369b747937054fff8e57 /backend/handlers/login.go | |
| parent | db: update new lp wrs (#88) (diff) | |
| download | lphub-ae4cec37e90ecc332cb1e7985e8a471c8efe385b.tar.gz lphub-ae4cec37e90ecc332cb1e7985e8a471c8efe385b.tar.bz2 lphub-ae4cec37e90ecc332cb1e7985e8a471c8efe385b.zip | |
feat: improved steam authentication (#57)
Former-commit-id: 2119371693f5a64bdaf5abfc6c1a3c66a3191320
Diffstat (limited to 'backend/handlers/login.go')
| -rw-r--r-- | backend/handlers/login.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/backend/handlers/login.go b/backend/handlers/login.go index dc6e4a5..b956c3c 100644 --- a/backend/handlers/login.go +++ b/backend/handlers/login.go | |||
| @@ -12,7 +12,7 @@ import ( | |||
| 12 | "github.com/golang-jwt/jwt/v4" | 12 | "github.com/golang-jwt/jwt/v4" |
| 13 | "github.com/pektezol/leastportalshub/backend/database" | 13 | "github.com/pektezol/leastportalshub/backend/database" |
| 14 | "github.com/pektezol/leastportalshub/backend/models" | 14 | "github.com/pektezol/leastportalshub/backend/models" |
| 15 | "github.com/solovev/steam_go" | 15 | "github.com/pektezol/steam_go" |
| 16 | ) | 16 | ) |
| 17 | 17 | ||
| 18 | type LoginResponse struct { | 18 | type LoginResponse struct { |
| @@ -28,14 +28,14 @@ type LoginResponse struct { | |||
| 28 | // @Success 200 {object} models.Response{data=LoginResponse} | 28 | // @Success 200 {object} models.Response{data=LoginResponse} |
| 29 | // @Router /login [get] | 29 | // @Router /login [get] |
| 30 | func Login(c *gin.Context) { | 30 | func Login(c *gin.Context) { |
| 31 | openID := steam_go.NewOpenId(c.Request) | 31 | openID := steam_go.NewOpenID(c.Request) |
| 32 | switch openID.Mode() { | 32 | switch openID.Mode() { |
| 33 | case "": | 33 | case "": |
| 34 | c.Redirect(http.StatusMovedPermanently, openID.AuthUrl()) | 34 | c.Redirect(http.StatusMovedPermanently, openID.AuthUrl()) |
| 35 | case "cancel": | 35 | case "cancel": |
| 36 | c.Redirect(http.StatusMovedPermanently, "/") | 36 | c.Redirect(http.StatusMovedPermanently, "/") |
| 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) |
| 41 | c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) | 41 | c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) |