A fork of the Cocoon PDS but being made more distributed.
11

Configure Feed

Select the types of activity you want to include in your feed.

better formatting for acocunt info

Hailey (Jul 12, 2025, 1:16 PM -0700) e7ec86c8 9ef3da08

+31 -10
+1
go.mod
··· 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 + 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
··· 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 + github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b h1:wDUNC2eKiL35DbLvsDhiblTUXHxcOPwQSCzi7xpQUN4= 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
··· 6 6 "github.com/haileyok/cocoon/oauth" 7 7 "github.com/haileyok/cocoon/oauth/constants" 8 8 "github.com/haileyok/cocoon/oauth/provider" 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 + 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 + now := time.Now() 42 + 39 43 tokenInfo := []map[string]string{} 40 44 for _, t := range tokens { 45 + ageRes := oauth.GetSessionAgeFromToken(t) 46 + maxTime := constants.PublicClientSessionLifetime 47 + if t.ClientAuth.Method != "none" { 48 + maxTime = constants.ConfidentialClientSessionLifetime 49 + } 50 + 51 + var clientName string 52 + metadata, err := s.oauthProvider.ClientManager.GetClient(ctx, t.ClientId) 53 + if err != nil { 54 + clientName = t.ClientId 55 + } else { 56 + clientName = metadata.Metadata.ClientName 57 + } 58 + 41 59 tokenInfo = append(tokenInfo, map[string]string{ 42 - "ClientId": t.ClientId, 43 - "CreatedAt": t.CreatedAt.Format("02 Jan 06 15:04 MST"), 44 - "UpdatedAt": t.CreatedAt.Format("02 Jan 06 15:04 MST"), 45 - "ExpiresAt": t.CreatedAt.Format("02 Jan 06 15:04 MST"), 46 - "Token": t.Token, 47 - "Ip": t.Ip, 60 + "ClientName": clientName, 61 + "Age": durafmt.Parse(ageRes.SessionAge).LimitFirstN(2).String(), 62 + "LastUpdated": durafmt.Parse(now.Sub(t.UpdatedAt)).LimitFirstN(2).String(), 63 + "ExpiresIn": durafmt.Parse(now.Add(maxTime).Sub(now)).LimitFirstN(2).String(), 64 + "Token": t.Token, 65 + "Ip": t.Ip, 48 66 }) 49 67 } 50 68
+4 -4
server/templates/account.html
··· 24 24 </div> 25 25 {{ else }} {{ range .Tokens }} 26 26 <div class="base-container"> 27 - <h4>{{ .ClientId }}</h4> 28 - <p>Created: {{ .CreatedAt }}</p> 29 - <p>Updated: {{ .UpdatedAt }}</p> 30 - <p>Expires: {{ .ExpiresAt }}</p> 27 + <h4>{{ .ClientName }}</h4> 28 + <p>Session Age: {{ .Age}}</p> 29 + <p>Last Updated: {{ .LastUpdated }} ago</p> 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 }}" />