From efdc47d22d72500822d71f772512dfb70e2a5b2f Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Sat, 29 Oct 2022 00:38:07 +0300 Subject: cleanup auth check and routes --- backend/controllers/controllers.go | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'backend/controllers/controllers.go') 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 ( "os" "time" - "github.com/gin-contrib/sessions" "github.com/gin-gonic/gin" "github.com/golang-jwt/jwt/v4" "github.com/pektezol/leastportals/backend/database" @@ -14,20 +13,13 @@ import ( ) func Home(c *gin.Context) { - session := sessions.Default(c) - if session.Get("id") == nil { + user, exists := c.Get("user") + if !exists { c.JSON(200, "no id, not auth") } else { - var user *steam_go.PlayerSummaries - user, err := steam_go.GetPlayerSummaries(session.Get("id").(string), os.Getenv("API_KEY")) - if err != nil { - c.JSON(200, "authenticated, but err") - log.Panic(err) - } else { - c.JSON(200, gin.H{ - "output": user, - }) - } + c.JSON(200, gin.H{ + "output": user, + }) } } @@ -95,10 +87,3 @@ func Logout(c *gin.Context) { //c.Redirect(http.StatusPermanentRedirect, "/") } } - -func Validate(c *gin.Context) { - user, _ := c.Get("user") - c.JSON(http.StatusOK, gin.H{ - "output": user, - }) -} -- cgit v1.2.3