Phase 13, part 5: each team's jobs, locks, files and sign-ins
Background jobs run for each active team on its own Server and under its own locks, a few teams at a time and from a different team each round, so the work is shared between copies of the app and no team holds up another. Each team's files are under its own prefix, and an OAuth sign-in comes back only to the team that started it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -417,7 +417,7 @@ func (s *Server) oauthStart(w http.ResponseWriter, r *http.Request) {
|
||||
s.serverError(w, err)
|
||||
return
|
||||
}
|
||||
p.For = forUser
|
||||
p.For, p.Team = forUser, s.team()
|
||||
// Kept in the database: the callback may reach another copy of the app.
|
||||
if err := s.DB.PutJSON(oauthFlowKey+p.State, p); err != nil {
|
||||
s.serverError(w, err)
|
||||
@@ -483,7 +483,7 @@ func (s *Server) oauthCallback(w http.ResponseWriter, r *http.Request) {
|
||||
if p != nil && p.For != 0 {
|
||||
back, nav = "/settings/account#posting", "settings/account"
|
||||
}
|
||||
if p == nil || p.Provider != provider || time.Since(p.Started) > oauthTTL {
|
||||
if p == nil || p.Provider != provider || time.Since(p.Started) > oauthTTL || (p.Team != 0 && p.Team != s.team()) {
|
||||
s.Log.Warn("oauth: callback with an unknown or expired state", "provider", provider)
|
||||
redirect(w, r, back, "oauth-expired")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user