userinfo: format exp, iat and updated_at (#2585)

This commit is contained in:
Caleb Doxsey 2021-09-10 06:23:54 -06:00 committed by GitHub
parent 4720199d59
commit 532b997fed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View file

@ -122,8 +122,12 @@
<td>{{$k}}</td>
<td>
{{range $v.AsSlice}}
{{if eq $k "exp" "iat" "updated_at"}}
<p>{{formatTime .}}</p>
{{else}}
<p>{{.}}</p>
{{end}}
{{end}}
</td>
</tr>
{{end}}

View file

@ -65,7 +65,20 @@ func NewTemplates() (*template.Template, error) {
"dataURL": func(p string) template.URL {
return dataURLs[strings.TrimPrefix(p, "/.pomerium/assets/")]
},
"formatTime": func(tm time.Time) string {
"formatTime": func(arg interface{}) string {
var tm time.Time
switch t := arg.(type) {
case float64:
tm = time.Unix(int64(t), 0)
case int:
tm = time.Unix(int64(t), 0)
case int64:
tm = time.Unix(t, 0)
case time.Time:
tm = t
default:
return "<INVALID TIME>"
}
return tm.Format("2006-01-02 15:04:05 MST")
},
})