Changeset 0.25.3 (#163)
This commit is contained in:
@@ -514,16 +514,30 @@ func (e *Engine) RenderWorkflow() gin.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// getUserContext extracts user info from gin context (set by auth middleware).
|
||||
// getUserContext extracts user info from gin context (set by auth middleware)
|
||||
// and enriches it with display name, username, and email from the database.
|
||||
func (e *Engine) getUserContext(c *gin.Context) *UserContext {
|
||||
userID, exists := c.Get("user_id")
|
||||
if !exists {
|
||||
return nil
|
||||
}
|
||||
return &UserContext{
|
||||
ID: userID.(string),
|
||||
Role: c.GetString("role"),
|
||||
uid := userID.(string)
|
||||
uc := &UserContext{
|
||||
ID: uid,
|
||||
Email: c.GetString("email"),
|
||||
Role: c.GetString("role"),
|
||||
}
|
||||
// Enrich from DB — username, display_name, and email may not be in JWT claims.
|
||||
if e.stores.Users != nil {
|
||||
if u, err := e.stores.Users.GetByID(c.Request.Context(), uid); err == nil && u != nil {
|
||||
uc.Username = u.Username
|
||||
uc.DisplayName = u.DisplayName
|
||||
if uc.Email == "" {
|
||||
uc.Email = u.Email
|
||||
}
|
||||
}
|
||||
}
|
||||
return uc
|
||||
}
|
||||
|
||||
// loadBanner reads banner config from global settings.
|
||||
|
||||
Reference in New Issue
Block a user