Compare commits

...

9 commits

Author SHA1 Message Date
grngxd
036d20561e Merge remote-tracking branch 'origin/dev' into auth-uploads 2025-06-08 19:00:09 +01:00
grngxd
b3057e185c delete route 2025-06-08 19:43:57 +02:00
grngxd
ea86ebc6a3 fix file retrieval 2025-06-08 19:43:57 +02:00
grngxd
56a907689e j 2025-06-08 19:43:57 +02:00
grngxd
f947cba89d sharing base64 file data 2025-06-08 19:43:57 +02:00
grngxd
c4f7f79cfd skibidi 2025-06-08 19:43:57 +02:00
grngxd
f2f1c28c71 add to db 2025-06-08 19:43:57 +02:00
grngxd
7733556c76 add auth to /uploads 2025-06-08 19:43:57 +02:00
hex
0521b523c4 feat: database user creation && readme explanation 2025-05-10 15:31:34 +02:00
11 changed files with 596 additions and 581 deletions

View file

@ -1,3 +1,8 @@
# stereo.cat backend
written in Go, uses Gin.
## database shit
Instead of using Discord oAuth as a database, we instead use it as a login source, only using it to source a username/id, avatar data and a secure login/registration flow.
We store these attributes alongside stereo.cat specific attributes in our own database. There is a trade-off however: this means that avatar & username data is not updated in real-time, only when the oauth flow is executed.

View file

@ -31,7 +31,17 @@ func RegisterAuthRoutes(cfg *types.StereoConfig, api *gin.RouterGroup) {
panic(err)
}
c.String(http.StatusOK, jwt)
res := cfg.Database.FirstOrCreate(&user)
if res.Error != nil {
panic(res.Error)
}
// TODO: redirect to dashboard
c.JSON(http.StatusOK, gin.H{
"jwt": jwt,
"known": res.RowsAffected == 0,
})
})
api.GET("/auth/me", auth.JwtMiddleware(cfg.JWTSecret), func(c *gin.Context) {