Documentation
¶
Overview ¶
Package shared provides shared types and utilities across packages.
Index ¶
- func GetJWTManager() *auth.JWTManager
- func GetSessionService() *service.SessionService
- func GetSystemSessionIdleTime() int
- func GetSystemSessionMaxTime() int
- func GetUserID(c *gin.Context) int
- func GetUserMapForTemplate(c *gin.Context) map[string]interface{}
- func IsAdmin(c *gin.Context) bool
- func IsAuthenticated(c *gin.Context) bool
- func LoadTicketStatesForForm(db *sql.DB) ([]gin.H, map[string]gin.H, error)
- func ResolveSessionTimeout(userPref int) int
- func SendToastResponse(c *gin.Context, success bool, message, redirectPath string)
- func SessionServiceAvailable() bool
- func SetGlobalRenderer(renderer *TemplateRenderer)
- type TemplateRenderer
- type UserContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetJWTManager ¶
func GetJWTManager() *auth.JWTManager
This ensures auth service and middleware use the same JWT configuration.
func GetSessionService ¶ added in v0.6.0
func GetSessionService() *service.SessionService
GetSessionService returns the global session service singleton. Returns nil if database is not available.
func GetSystemSessionIdleTime ¶ added in v0.5.0
func GetSystemSessionIdleTime() int
GetSystemSessionIdleTime returns the configured idle timeout in seconds.
func GetSystemSessionMaxTime ¶ added in v0.5.0
func GetSystemSessionMaxTime() int
GetSystemSessionMaxTime returns the configured session lifetime in seconds.
func GetUserMapForTemplate ¶ added in v0.5.0
GetUserMapForTemplate builds a user context map for template rendering.
func IsAuthenticated ¶ added in v0.5.0
IsAuthenticated checks if user is authenticated.
func LoadTicketStatesForForm ¶ added in v0.5.0
LoadTicketStatesForForm fetches valid ticket states and builds alias lookup data for forms.
func ResolveSessionTimeout ¶ added in v0.5.0
ResolveSessionTimeout picks the effective timeout based on user preference.
func SendToastResponse ¶ added in v0.5.0
sendToastResponse sends either an HTMX toast notification or redirects with success message.
func SessionServiceAvailable ¶ added in v0.6.0
func SessionServiceAvailable() bool
SessionServiceAvailable returns true if the session service is available.
func SetGlobalRenderer ¶ added in v0.5.0
func SetGlobalRenderer(renderer *TemplateRenderer)
SetGlobalRenderer sets the global template renderer instance.
Types ¶
type TemplateRenderer ¶ added in v0.5.0
type TemplateRenderer struct {
// contains filtered or unexported fields
}
TemplateRenderer handles template rendering with pongo2.
func GetGlobalRenderer ¶ added in v0.5.0
func GetGlobalRenderer() *TemplateRenderer
GetGlobalRenderer returns the global template renderer instance.
func NewTemplateRenderer ¶ added in v0.5.0
func NewTemplateRenderer(templateDir string) (*TemplateRenderer, error)
NewTemplateRenderer creates a new template renderer.
func (*TemplateRenderer) HTML ¶ added in v0.5.0
func (r *TemplateRenderer) HTML(c *gin.Context, code int, name string, data interface{})
HTML renders a template.
func (*TemplateRenderer) TemplateSet ¶ added in v0.5.0
func (r *TemplateRenderer) TemplateSet() *pongo2.TemplateSet
TemplateSet returns the underlying pongo2 template set for modules that need direct access.
type UserContext ¶ added in v0.5.0
type UserContext struct {
ID int `json:"id"`
Login string `json:"login"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Email string `json:"email"`
IsInAdminGroup bool `json:"is_in_admin_group"`
GroupIDs []int `json:"group_ids"`
RoleIDs []int `json:"role_ids"`
CustomerCompany string `json:"customer_company"`
}
UserContext represents user information for templates.