This commit is contained in:
hexlocation 2025-06-08 21:13:32 +02:00
parent 57137a08d3
commit c5aa21b75e
6 changed files with 23 additions and 9 deletions

View file

@ -38,10 +38,13 @@ func RegisterAuthRoutes(cfg *types.StereoConfig, api *gin.RouterGroup) {
}
// TODO: redirect to dashboard
c.JSON(http.StatusOK, gin.H{
/*c.JSON(http.StatusOK, gin.H{
"jwt": jwt,
"known": res.RowsAffected == 0,
})
*/
c.SetCookie("jwt", jwt, int(t.ExpiresIn), "", cfg.Domain, true, true)
c.Redirect(http.StatusTemporaryRedirect, cfg.FrontendUri)
})
api.GET("/auth/me", auth.JwtMiddleware(cfg.JWTSecret), func(c *gin.Context) {

View file

@ -48,7 +48,6 @@ func RegisterFileRoutes(cfg *types.StereoConfig, api *gin.RouterGroup) {
fileMeta := types.File{
ID: uid + "_" + file.Filename,
Path: filePath,
Owner: uid,
CreatedAt: time.Now(),
Size: file.Size,

View file

@ -15,16 +15,17 @@ type Route struct {
}
type StereoConfig struct {
ImagePath string
Router *gin.Engine
Client client.Client
Database *gorm.DB
JWTSecret string
ImagePath string
Router *gin.Engine
Client client.Client
Database *gorm.DB
JWTSecret string
FrontendUri string
Domain string
}
type File struct {
ID string `gorm:"primaryKey"`
Path string `gorm:"not null;index"`
Owner string `gorm:"not null;index"`
Size int64 `gorm:"not null;type:bigint"`
CreatedAt time.Time `gorm:"autoCreateTime"`