alpha
Login
or
Join now
willdot.net
/
distributed-pds
forked from
willdot.net/cocoon
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
A fork of the Cocoon PDS but being made more distributed.
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
better formatting for acocunt info
author
Hailey
date
11 months ago
(Jul 12, 2025, 1:16 PM -0700)
commit
e7ec86c8
e7ec86c8ca63e13a0a6d0c654ae74119c40357b2
parent
9ef3da08
9ef3da0831c0dbcf21ba615fa6b202bc8b914c44
+31
-10
4 changed files
Expand all
Collapse all
Unified
Split
go.mod
go.sum
server
handle_account.go
templates
account.html
+1
go.mod
Reviewed
···
14
14
github.com/google/uuid v1.4.0
15
15
github.com/gorilla/sessions v1.4.0
16
16
github.com/gorilla/websocket v1.5.1
17
17
+
github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b
17
18
github.com/hashicorp/golang-lru/v2 v2.0.7
18
19
github.com/ipfs/go-block-format v0.2.0
19
20
github.com/ipfs/go-cid v0.4.1
+2
go.sum
Reviewed
···
91
91
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
92
92
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8=
93
93
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4=
94
94
+
github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b h1:wDUNC2eKiL35DbLvsDhiblTUXHxcOPwQSCzi7xpQUN4=
95
95
+
github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b/go.mod h1:VzxiSdG6j1pi7rwGm/xYI5RbtpBgM8sARDXlvEvxlu0=
94
96
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
95
97
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
96
98
github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI=
+24
-6
server/handle_account.go
Reviewed
···
6
6
"github.com/haileyok/cocoon/oauth"
7
7
"github.com/haileyok/cocoon/oauth/constants"
8
8
"github.com/haileyok/cocoon/oauth/provider"
9
9
+
"github.com/hako/durafmt"
9
10
"github.com/labstack/echo/v4"
10
11
)
11
12
12
13
func (s *Server) handleAccount(e echo.Context) error {
14
14
+
ctx := e.Request().Context()
13
15
repo, sess, err := s.getSessionRepoOrErr(e)
14
16
if err != nil {
15
17
return e.Redirect(303, "/account/signin")
···
36
38
filtered = append(filtered, t)
37
39
}
38
40
41
41
+
now := time.Now()
42
42
+
39
43
tokenInfo := []map[string]string{}
40
44
for _, t := range tokens {
45
45
+
ageRes := oauth.GetSessionAgeFromToken(t)
46
46
+
maxTime := constants.PublicClientSessionLifetime
47
47
+
if t.ClientAuth.Method != "none" {
48
48
+
maxTime = constants.ConfidentialClientSessionLifetime
49
49
+
}
50
50
+
51
51
+
var clientName string
52
52
+
metadata, err := s.oauthProvider.ClientManager.GetClient(ctx, t.ClientId)
53
53
+
if err != nil {
54
54
+
clientName = t.ClientId
55
55
+
} else {
56
56
+
clientName = metadata.Metadata.ClientName
57
57
+
}
58
58
+
41
59
tokenInfo = append(tokenInfo, map[string]string{
42
42
-
"ClientId": t.ClientId,
43
43
-
"CreatedAt": t.CreatedAt.Format("02 Jan 06 15:04 MST"),
44
44
-
"UpdatedAt": t.CreatedAt.Format("02 Jan 06 15:04 MST"),
45
45
-
"ExpiresAt": t.CreatedAt.Format("02 Jan 06 15:04 MST"),
46
46
-
"Token": t.Token,
47
47
-
"Ip": t.Ip,
60
60
+
"ClientName": clientName,
61
61
+
"Age": durafmt.Parse(ageRes.SessionAge).LimitFirstN(2).String(),
62
62
+
"LastUpdated": durafmt.Parse(now.Sub(t.UpdatedAt)).LimitFirstN(2).String(),
63
63
+
"ExpiresIn": durafmt.Parse(now.Add(maxTime).Sub(now)).LimitFirstN(2).String(),
64
64
+
"Token": t.Token,
65
65
+
"Ip": t.Ip,
48
66
})
49
67
}
50
68
+4
-4
server/templates/account.html
Reviewed
···
24
24
</div>
25
25
{{ else }} {{ range .Tokens }}
26
26
<div class="base-container">
27
27
-
<h4>{{ .ClientId }}</h4>
28
28
-
<p>Created: {{ .CreatedAt }}</p>
29
29
-
<p>Updated: {{ .UpdatedAt }}</p>
30
30
-
<p>Expires: {{ .ExpiresAt }}</p>
27
27
+
<h4>{{ .ClientName }}</h4>
28
28
+
<p>Session Age: {{ .Age}}</p>
29
29
+
<p>Last Updated: {{ .LastUpdated }} ago</p>
30
30
+
<p>Expires In: {{ .ExpiresIn }}</p>
31
31
<p>IP Address: {{ .Ip }}</p>
32
32
<form action="/account/revoke" method="post">
33
33
<input type="hidden" name="token" value="{{ .Token }}" />