this repo has no description
0
fork

Configure Feed

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

demo cleanups

+20 -12
-3
atproto/auth/oauth/cmd/oauth-web-demo/base.html
··· 31 31 </header> 32 32 <main> 33 33 <section class="content"> 34 - {{ range 0 }} 35 - <article>{{ . }}</article> 36 - {{ end }} 37 34 {{ template "content" . }} 38 35 </section> 39 36 </main>
+20 -9
atproto/auth/oauth/cmd/oauth-web-demo/main.go
··· 137 137 return nil 138 138 } 139 139 140 - func (s *Server) loadOAuthSession(r *http.Request) (*oauth.ClientSession, error) { 141 - ctx := r.Context() 142 - 140 + func (s *Server) currentSessionDID(r *http.Request) *syntax.DID { 143 141 sess, _ := s.CookieStore.Get(r, "oauth-demo") 144 142 accountDID, ok := sess.Values["account_did"].(string) 145 143 if !ok || accountDID == "" { 146 - return nil, fmt.Errorf("not authenticated") 144 + return nil 147 145 } 148 146 did, err := syntax.ParseDID(accountDID) 149 147 if err != nil { 150 - return nil, err 148 + return nil 151 149 } 152 150 153 - return s.OAuth.ResumeSession(ctx, did) 151 + return &did 154 152 } 155 153 156 154 func strPtr(raw string) *string { ··· 245 243 func (s *Server) OAuthRefresh(w http.ResponseWriter, r *http.Request) { 246 244 ctx := r.Context() 247 245 248 - oauthSess, err := s.loadOAuthSession(r) 249 - if err != nil { 246 + did := s.currentSessionDID(r) 247 + if did == nil { 250 248 // TODO: suppowed to set a WWW header; and could redirect? 249 + http.Error(w, "not authenticated", http.StatusUnauthorized) 250 + return 251 + } 252 + 253 + oauthSess, err := s.OAuth.ResumeSession(ctx, *did) 254 + if err != nil { 251 255 http.Error(w, "not authenticated", http.StatusUnauthorized) 252 256 return 253 257 } ··· 286 290 return 287 291 } 288 292 289 - oauthSess, err := s.loadOAuthSession(r) 293 + did := s.currentSessionDID(r) 294 + if did == nil { 295 + // TODO: suppowed to set a WWW header; and could redirect? 296 + http.Error(w, "not authenticated", http.StatusUnauthorized) 297 + return 298 + } 299 + 300 + oauthSess, err := s.OAuth.ResumeSession(ctx, *did) 290 301 if err != nil { 291 302 http.Error(w, "not authenticated", http.StatusUnauthorized) 292 303 return