feat: database user creation && readme explanation
This commit is contained in:
parent
fbd23fe2cf
commit
0521b523c4
2 changed files with 17 additions and 2 deletions
|
@ -31,11 +31,21 @@ 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) {
|
||||
claims, _ := c.Get("claims")
|
||||
claims, _ := c.Get("claims")
|
||||
c.JSON(http.StatusOK, claims)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue