Phase 13, part 3: signing up, and several teams per person

On the multi-tenant edition anyone can set up a team: their account, the
company and its website, whose registered domain the team works on (the
profile keeps to it). A person can belong to several teams and switch
between them from the sidebar, or set up another. Inviting someone who has
an account adds them to the team.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 12:17:15 -07:00
co-authored by Claude Opus 5.5
parent 210b1e57fc
commit d5fb1898e8
16 changed files with 545 additions and 13 deletions
+14 -2
View File
@@ -224,8 +224,20 @@ func (s *Server) userInvite(w http.ResponseWriter, r *http.Request) {
f.Problem = "Give them at least one module, or make them an admin."
}
if f.Problem == "" {
if _, err := users.ByEmail(s.DB, email); err == nil {
f.Problem = "Someone has that email address already: they're in the list below."
if old, err := users.ByEmail(s.platform(), email); err == nil {
// On the multi-tenant edition, someone from another team: added
// to this one, with the account they have.
if _, err := users.MembershipOf(s.platform(), s.team(), old.ID); err == nil || !s.multi() || old.Kind != users.Person {
f.Problem = "Someone has that email address already: they're in the list below."
} else {
if err := s.addExisting(v, old, role, mods, time.Now()); err != nil {
s.serverError(w, err)
return
}
s.audit(r, "invited", old.Email, accessText(users.Membership{Role: role, Modules: mods})+" (an existing account)")
redirect(w, r, "/settings/users", "added")
return
}
} else if !errors.Is(err, users.ErrNotFound) {
s.serverError(w, err)
return