feat(webui): add a member by provider subject or email
POST /api/orgs/{id}/members binds a person by subject, or by email as a
placeholder. The first sign-in whose provider vouches for that email
claims it: the State Store moves the binding onto the provider's subject
in one statement, so a second account with the same address finds
nothing to claim and later sign-ins rest on the subject alone.
This commit is contained in:
1 parent
9e1a40ce99
commit
37cbf2ef47
17 files changed
+2085
-1505
No files matched your search
@@ -10,6 +10,33 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const claimIdentitySubject = `-- name: ClaimIdentitySubject :one
|
||||
UPDATE identity_subjects SET subject = $1, bound_at = $2
|
||||
WHERE issuer = $3 AND subject = $4
|
||||
RETURNING identity_id
|
||||
`
|
||||
|
||||
type ClaimIdentitySubjectParams struct {
|
||||
Subject string
|
||||
BoundAt time.Time
|
||||
Issuer string
|
||||
Placeholder string
|
||||
}
|
||||
|
||||
// Moves a placeholder binding onto the subject the provider asserts, in one
|
||||
// statement, so only the first claimant gets it.
|
||||
func (q *Queries) ClaimIdentitySubject(ctx context.Context, arg ClaimIdentitySubjectParams) (string, error) {
|
||||
row := q.db.QueryRow(ctx, claimIdentitySubject,
|
||||
arg.Subject,
|
||||
arg.BoundAt,
|
||||
arg.Issuer,
|
||||
arg.Placeholder,
|
||||
)
|
||||
var identity_id string
|
||||
err := row.Scan(&identity_id)
|
||||
return identity_id, err
|
||||
}
|
||||
|
||||
const deleteIdentitySubject = `-- name: DeleteIdentitySubject :execrows
|
||||
DELETE FROM identity_subjects WHERE identity_id = $1 AND issuer = $2 AND subject = $3
|
||||
`
|
||||
|
||||
Reference in new issue
Block a user