diff --git a/client.apk b/client.apk new file mode 100644 index 0000000..6b2b991 --- /dev/null +++ b/client.apk @@ -0,0 +1 @@ +"wallah je suis l'apk" diff --git a/controller/users.go b/controller/users.go index bb8dc9f..9a3f7ce 100644 --- a/controller/users.go +++ b/controller/users.go @@ -95,3 +95,14 @@ func GetUserServices(ctx *gin.Context) { ctx.JSON(http.StatusOK, serviceTokens) } + +func GetSelfUserId(ctx *gin.Context) { + userInterface, exists := ctx.Get("user") + if !exists { + ctx.JSON(http.StatusUnauthorized, gin.H{"error": "User not authenticated"}) + return + } + + user := userInterface.(*db.UsersModel) + ctx.JSON(http.StatusOK, gin.H{"userId": user.ID}) +} diff --git a/download/apk.go b/download/apk.go new file mode 100644 index 0000000..aa28b14 --- /dev/null +++ b/download/apk.go @@ -0,0 +1,7 @@ +package download + +import "github.com/gin-gonic/gin" + +func DownloadApk(ctx *gin.Context) { + ctx.File("./client.apk") +} diff --git a/router/router.go b/router/router.go index dc8887b..105d2b1 100644 --- a/router/router.go +++ b/router/router.go @@ -5,6 +5,7 @@ import ( "github.com/ValianceTekProject/AreaBack/authentification" "github.com/ValianceTekProject/AreaBack/controller" + "github.com/ValianceTekProject/AreaBack/download" "github.com/ValianceTekProject/AreaBack/engine" "github.com/ValianceTekProject/AreaBack/middleware" "github.com/gin-contrib/cors" @@ -44,6 +45,7 @@ func setupAuthRouter(router *gin.Engine) *gin.Engine { router.GET("/auth/discord/callback", authentification.DiscordCallback) router.GET("/about.json", engine.GetAbout) + router.GET("/client.apk", download.DownloadApk) return router } @@ -61,6 +63,7 @@ func setupProtectedRouter(router *gin.Engine) *gin.Engine { protectedRoute.POST("/areas/create", controller.CreateArea) protectedRoute.GET("/areas", controller.GetUserAreas) + protectedRoute.GET("/me/userId", controller.GetSelfUserId) protectedRoute.GET("/users/:userId", controller.GetSpecificUser) protectedRoute.GET("/services/:userId", controller.GetUserServices) protectedRoute.PATCH("/areas/:areaId/status", controller.UpdateAreaStatus)