feat: basic auth shit + db init

This commit is contained in:
hexlocation 2025-05-05 19:34:28 +02:00
parent db49da5fd9
commit d8caef7e5d
10 changed files with 261 additions and 69 deletions

View file

@ -8,4 +8,5 @@ import (
func Register(cfg *types.StereoConfig) {
api := cfg.Router.Group("/api")
routes.RegisterUploadRoutes(cfg, api)
routes.RegisterAuthRoutes(cfg, api)
}

View file

@ -0,0 +1,28 @@
package routes
import (
"net/http"
"github.com/gin-gonic/gin"
"stereo.cat/backend/internal/types"
)
func RegisterAuthRoutes(cfg *types.StereoConfig, api *gin.RouterGroup) {
api.GET("/auth/callback", func(c *gin.Context) {
code := c.Query("code")
t, err := cfg.Client.ExchangeCode(code)
if err != nil {
panic(err)
}
user, err := cfg.Client.GetUser(t)
if err != nil {
panic(err)
}
c.JSON(http.StatusOK, user)
})
}