this repo has no description
0
fork

Configure Feed

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

fix demo current session links

+26 -14
+3 -5
atproto/auth/oauth/cmd/oauth-web-demo/base.html
··· 12 12 <header> 13 13 <hgroup> 14 14 <h1>atproto OAuth demo (indigo)</h1> 15 - {{ if false }} 16 - <p>Hello <span style="font-family: monospace;">@{{ "handle" }}</span>!</p> 17 - {{ end }} 18 15 </hgroup> 19 16 <nav> 20 17 <ul> 21 - {{ if false }} 18 + {{ if . }} 19 + <li><span style="font-family: monospace; font-weight: bold;">{{ . }}</span> 22 20 <li><a href="/bsky/post">Create Post</a> 23 - <li><a href="/oauth/refresh">Refresh Token</a> 21 + <li><a href="/oauth/refresh">Refresh Tokens</a> 24 22 <li><a href="/oauth/logout">Logout</a> 25 23 {{ else }} 26 24 <li><a href="/oauth/login">Login</a>
+23 -9
atproto/auth/oauth/cmd/oauth-web-demo/main.go
··· 76 76 var tmplPostText string 77 77 var tmplPost = template.Must(template.Must(template.New("post.html").Parse(tmplBaseText)).Parse(tmplPostText)) 78 78 79 - func (s *Server) Homepage(w http.ResponseWriter, r *http.Request) { 80 - tmplHome.Execute(w, nil) 81 - } 82 - 83 79 func runServer(cctx *cli.Context) error { 84 80 85 81 scopes := []string{"atproto", "transition:generic"} ··· 194 190 } 195 191 } 196 192 193 + func (s *Server) Homepage(w http.ResponseWriter, r *http.Request) { 194 + ctx := r.Context() 195 + 196 + // attempts to load Session to display links 197 + did, sessionID := s.currentSessionDID(r) 198 + if did == nil { 199 + tmplHome.Execute(w, nil) 200 + return 201 + } 202 + 203 + _, err := s.OAuth.ResumeSession(ctx, *did, sessionID) 204 + if err != nil { 205 + tmplHome.Execute(w, nil) 206 + return 207 + } 208 + tmplHome.Execute(w, did) 209 + } 210 + 197 211 func (s *Server) OAuthLogin(w http.ResponseWriter, r *http.Request) { 198 212 ctx := r.Context() 199 213 ··· 300 314 301 315 slog.Info("in post handler") 302 316 303 - if r.Method != "POST" { 304 - tmplPost.Execute(w, nil) 305 - return 306 - } 307 - 308 317 did, sessionID := s.currentSessionDID(r) 309 318 if did == nil { 310 319 // TODO: supposed to set a WWW header; and could redirect? 311 320 http.Error(w, "not authenticated", http.StatusUnauthorized) 321 + return 322 + } 323 + 324 + if r.Method != "POST" { 325 + tmplPost.Execute(w, did) 312 326 return 313 327 } 314 328