feat: terms of service and versioned consent; data rights for every account
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 9m21s
ci / test (pull_request) Successful in 13m53s
ci / build (pull_request) Successful in 11m22s
ci / image (pull_request) Successful in 4m36s
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 9m21s
ci / test (pull_request) Successful in 13m53s
ci / build (pull_request) Successful in 11m22s
ci / image (pull_request) Successful in 4m36s
Terms of service join the legal notice and privacy policy, for the platform only. Every account accepts the platform's privacy policy and terms: on sign-up (also through an invitation) by ticking a box for the versions shown, and after a sign-in through a provider right away. When an admin saves a material change with "everyone has to accept again", the document gets a new version and each account is asked at its next request; corrections ask nobody. Acceptances are kept per version with their time, as proof, and are part of the data export. Until an account accepted, and while it is suspended, it can read the documents, export its data, delete itself and sign out, nothing else: pages lead to /consent or /account/suspended, other API calls answer 403 consent_required or account_suspended. Suspended accounts therefore sign in again, by password or provider; their API tokens stay blocked. Deleting an account deletes the organizations it owns, monitors and all, also when they have other members (each organization has one owner); it no longer refuses. The account settings name those organizations first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
61fdfa830a
commit
8d7c1f856c
38 files changed
+2033
-354
No files matched your search
+16
-10
@@ -35,6 +35,10 @@ type signupRequest struct {
|
||||
// after confirming.
|
||||
OrgName string `json:"org_name" binding:"max=200"`
|
||||
OrgSlug string `json:"org_slug" binding:"max=63"`
|
||||
// Consent accepts the platform's privacy policy and terms in the
|
||||
// versions the form showed (ConsentVersions, "privacy:12,terms:14").
|
||||
Consent bool `json:"consent"`
|
||||
ConsentVersions string `json:"consent_versions" binding:"max=200"`
|
||||
}
|
||||
|
||||
func (s *Server) signup(c *gin.Context) {
|
||||
@@ -60,6 +64,10 @@ func (s *Server) signup(c *gin.Context) {
|
||||
fail(c, http.StatusTooManyRequests, "signup_limit")
|
||||
return
|
||||
}
|
||||
consent, ok := s.signupConsent(c, req.Consent, req.ConsentVersions)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
verify := s.verificationRequired()
|
||||
withOrg := !verify && strings.TrimSpace(req.OrgName) != "" && strings.TrimSpace(req.OrgSlug) != ""
|
||||
hash, err := auth.HashPassword(req.Password)
|
||||
@@ -103,6 +111,11 @@ func (s *Server) signup(c *gin.Context) {
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err == nil {
|
||||
err = s.db.Tx(ctx, tenant.User(user.ID), func(q *store.Queries) error {
|
||||
return recordConsent(ctx, q, user.ID, consent)
|
||||
})
|
||||
}
|
||||
switch {
|
||||
case isUniqueViolation(err, "users_email_key"), isUniqueViolation(err, "users_email_key_idx"):
|
||||
fail(c, http.StatusConflict, "email_taken")
|
||||
@@ -195,12 +208,9 @@ func (s *Server) login(c *gin.Context) {
|
||||
invalidCredentials(c)
|
||||
return
|
||||
}
|
||||
// Only someone who knows the password learns of the suspension or a
|
||||
// missing confirmation.
|
||||
if user.DisabledAt != nil {
|
||||
fail(c, http.StatusForbidden, "account_suspended")
|
||||
return
|
||||
}
|
||||
// Only someone who knows the password learns of a missing
|
||||
// confirmation. Suspended accounts sign in, but only to export or
|
||||
// delete their data.
|
||||
if user.EmailVerifiedAt == nil {
|
||||
fail(c, http.StatusForbidden, "email_unverified")
|
||||
return
|
||||
@@ -289,10 +299,6 @@ func (s *Server) finishLogin(c *gin.Context, userID uuid.UUID, method auth.Metho
|
||||
internalError(c, err)
|
||||
return
|
||||
}
|
||||
if user.DisabledAt != nil {
|
||||
fail(c, http.StatusForbidden, "account_suspended")
|
||||
return
|
||||
}
|
||||
var org uuid.UUID
|
||||
if len(orgs) > 0 {
|
||||
org = orgs[0].ID
|
||||
|
||||
Reference in new issue
Block a user