From 3be6a02ba0a6200e71bd0b97a040075966dfc302 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Sat, 6 May 2023 17:41:12 +0300 Subject: feat: get token endpoint --- backend/controllers/loginController.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'backend/controllers/loginController.go') diff --git a/backend/controllers/loginController.go b/backend/controllers/loginController.go index c533757..06cc0ba 100644 --- a/backend/controllers/loginController.go +++ b/backend/controllers/loginController.go @@ -83,6 +83,30 @@ func Login(c *gin.Context) { } } +// GET Token +// +// @Summary Gets the token cookie value from the user. +// @Tags auth +// @Produce json +// +// @Success 200 {object} models.Respnose{data=models.LoginResponse} +// @Failure 404 {object} models.Response +// @Router /token [get] +func GetCookie(c *gin.Context) { + cookie, err := c.Cookie("token") + if err != nil { + c.JSON(http.StatusNotFound, models.ErrorResponse("No token cookie found.")) + return + } + c.JSON(http.StatusOK, models.Response{ + Success: true, + Message: "Token cookie successfully retrieved.", + Data: models.LoginResponse{ + Token: cookie, + }, + }) +} + func GetPlayerSummaries(steamId, apiKey string) (*models.PlayerSummaries, error) { url := fmt.Sprintf("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key=%s&steamids=%s", apiKey, steamId) resp, err := http.Get(url) -- cgit v1.2.3