mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-06 10:21:05 +02:00
userinfo: format exp, iat and updated_at (#2585)
This commit is contained in:
parent
4720199d59
commit
532b997fed
2 changed files with 18 additions and 1 deletions
|
@ -122,7 +122,11 @@
|
|||
<td>{{$k}}</td>
|
||||
<td>
|
||||
{{range $v.AsSlice}}
|
||||
{{if eq $k "exp" "iat" "updated_at"}}
|
||||
<p>{{formatTime .}}</p>
|
||||
{{else}}
|
||||
<p>{{.}}</p>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -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")
|
||||
},
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue