diff options
Diffstat (limited to 'backend/controllers/controllers.go')
| -rw-r--r-- | backend/controllers/controllers.go | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/backend/controllers/controllers.go b/backend/controllers/controllers.go index 79fc223..6a38e8c 100644 --- a/backend/controllers/controllers.go +++ b/backend/controllers/controllers.go | |||
| @@ -6,7 +6,6 @@ import ( | |||
| 6 | "os" | 6 | "os" |
| 7 | "time" | 7 | "time" |
| 8 | 8 | ||
| 9 | "github.com/gin-contrib/sessions" | ||
| 10 | "github.com/gin-gonic/gin" | 9 | "github.com/gin-gonic/gin" |
| 11 | "github.com/golang-jwt/jwt/v4" | 10 | "github.com/golang-jwt/jwt/v4" |
| 12 | "github.com/pektezol/leastportals/backend/database" | 11 | "github.com/pektezol/leastportals/backend/database" |
| @@ -14,20 +13,13 @@ import ( | |||
| 14 | ) | 13 | ) |
| 15 | 14 | ||
| 16 | func Home(c *gin.Context) { | 15 | func Home(c *gin.Context) { |
| 17 | session := sessions.Default(c) | 16 | user, exists := c.Get("user") |
| 18 | if session.Get("id") == nil { | 17 | if !exists { |
| 19 | c.JSON(200, "no id, not auth") | 18 | c.JSON(200, "no id, not auth") |
| 20 | } else { | 19 | } else { |
| 21 | var user *steam_go.PlayerSummaries | 20 | c.JSON(200, gin.H{ |
| 22 | user, err := steam_go.GetPlayerSummaries(session.Get("id").(string), os.Getenv("API_KEY")) | 21 | "output": user, |
| 23 | if err != nil { | 22 | }) |
| 24 | c.JSON(200, "authenticated, but err") | ||
| 25 | log.Panic(err) | ||
| 26 | } else { | ||
| 27 | c.JSON(200, gin.H{ | ||
| 28 | "output": user, | ||
| 29 | }) | ||
| 30 | } | ||
| 31 | } | 23 | } |
| 32 | } | 24 | } |
| 33 | 25 | ||
| @@ -95,10 +87,3 @@ func Logout(c *gin.Context) { | |||
| 95 | //c.Redirect(http.StatusPermanentRedirect, "/") | 87 | //c.Redirect(http.StatusPermanentRedirect, "/") |
| 96 | } | 88 | } |
| 97 | } | 89 | } |
| 98 | |||
| 99 | func Validate(c *gin.Context) { | ||
| 100 | user, _ := c.Get("user") | ||
| 101 | c.JSON(http.StatusOK, gin.H{ | ||
| 102 | "output": user, | ||
| 103 | }) | ||
| 104 | } | ||