update
This commit is contained in:
@@ -75,6 +75,7 @@ type auditRecord struct {
|
||||
Hostname string
|
||||
PackageSlug string
|
||||
SourceIP string
|
||||
LANIP string
|
||||
Details string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
@@ -125,7 +126,7 @@ func New(cfg Config) (*Server, error) {
|
||||
return nil, fmt.Errorf("database: %w", err)
|
||||
}
|
||||
|
||||
templates, err := parseTemplates()
|
||||
templates, err := parseTemplates(cfg.DisplayTimeZone)
|
||||
if err != nil {
|
||||
_ = db.Close()
|
||||
return nil, err
|
||||
@@ -162,10 +163,13 @@ func New(cfg Config) (*Server, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func parseTemplates() (*template.Template, error) {
|
||||
func parseTemplates(displayTimeZone *time.Location) (*template.Template, error) {
|
||||
if displayTimeZone == nil {
|
||||
displayTimeZone = time.UTC
|
||||
}
|
||||
return template.New("").Funcs(template.FuncMap{
|
||||
"formatTime": func(value time.Time) string {
|
||||
return value.Local().Format("Jan 2, 2006 3:04 PM")
|
||||
return value.In(displayTimeZone).Format("Jan 2, 2006 3:04 PM MST")
|
||||
},
|
||||
"isActive": func(record authorizationRecord) bool {
|
||||
return !record.RevokedAt.Valid && time.Now().Before(record.ExpiresAt)
|
||||
|
||||
Reference in New Issue
Block a user