Compare commits
1 commit
auth-uploa
...
dev
Author | SHA1 | Date | |
---|---|---|---|
0521b523c4 |
2 changed files with 17 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
||||||
# stereo.cat backend
|
# stereo.cat backend
|
||||||
|
|
||||||
written in Go, uses Gin.
|
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.
|
||||||
|
|
|
@ -31,7 +31,17 @@ func RegisterAuthRoutes(cfg *types.StereoConfig, api *gin.RouterGroup) {
|
||||||
panic(err)
|
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) {
|
api.GET("/auth/me", auth.JwtMiddleware(cfg.JWTSecret), func(c *gin.Context) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue