aboutsummaryrefslogtreecommitdiff
path: root/backend/controllers/loginController.go
diff options
context:
space:
mode:
authorArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2023-05-06 19:53:25 +0300
committerArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2023-05-06 19:53:25 +0300
commitfbdc0b813944937af29da74f4790e52a2522c480 (patch)
tree94f47aaeec7bdf4eab60db340ef654ac391ed9e9 /backend/controllers/loginController.go
parentdoc: token endpoint (diff)
downloadlphub-fbdc0b813944937af29da74f4790e52a2522c480.tar.gz
lphub-fbdc0b813944937af29da74f4790e52a2522c480.tar.bz2
lphub-fbdc0b813944937af29da74f4790e52a2522c480.zip
feat: logout endpoint
Diffstat (limited to 'backend/controllers/loginController.go')
-rw-r--r--backend/controllers/loginController.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/backend/controllers/loginController.go b/backend/controllers/loginController.go
index 6e1c299..cfe086d 100644
--- a/backend/controllers/loginController.go
+++ b/backend/controllers/loginController.go
@@ -107,6 +107,31 @@ func GetCookie(c *gin.Context) {
107 }) 107 })
108} 108}
109 109
110// DELETE Token
111//
112// @Summary Deletes the token cookie from the user.
113// @Tags auth
114// @Produce json
115//
116// @Success 200 {object} models.Response{data=models.LoginResponse}
117// @Failure 404 {object} models.Response
118// @Router /token [delete]
119func DeleteCookie(c *gin.Context) {
120 cookie, err := c.Cookie("token")
121 if err != nil {
122 c.JSON(http.StatusNotFound, models.ErrorResponse("No token cookie found."))
123 return
124 }
125 c.SetCookie("token", "", -1, "/", "", true, true)
126 c.JSON(http.StatusOK, models.Response{
127 Success: true,
128 Message: "Token cookie successfully deleted.",
129 Data: models.LoginResponse{
130 Token: cookie,
131 },
132 })
133}
134
110func GetPlayerSummaries(steamId, apiKey string) (*models.PlayerSummaries, error) { 135func GetPlayerSummaries(steamId, apiKey string) (*models.PlayerSummaries, error) {
111 url := fmt.Sprintf("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key=%s&steamids=%s", apiKey, steamId) 136 url := fmt.Sprintf("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key=%s&steamids=%s", apiKey, steamId)
112 resp, err := http.Get(url) 137 resp, err := http.Get(url)