[bug] Fix OIDC users requiring second approval (#371)

* tidy up NewSignup
* pre-approve users created via OIDC
This commit is contained in:
tobi 2022-01-31 16:03:47 +01:00 committed by GitHub
commit 18e7537393
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 13 deletions

View file

@ -94,13 +94,13 @@ func (a *adminDB) NewSignup(ctx context.Context, username string, reason string,
// if something went wrong while creating a user, we might already have an account, so check here first...
acct := &gtsmodel.Account{}
err = a.conn.NewSelect().
q := a.conn.NewSelect().
Model(acct).
Where("username = ?", username).
WhereGroup(" AND ", whereEmptyOrNull("domain")).
Scan(ctx)
if err != nil {
// we just don't have an account yet so create one
WhereGroup(" AND ", whereEmptyOrNull("domain"))
if err := q.Scan(ctx); err != nil {
// we just don't have an account yet so create one before we proceed
accountURIs := uris.GenerateURIsForAccount(username)
accountID, err := id.NewRandomULID()
if err != nil {
@ -125,6 +125,7 @@ func (a *adminDB) NewSignup(ctx context.Context, username string, reason string,
FollowingURI: accountURIs.FollowingURI,
FeaturedCollectionURI: accountURIs.CollectionURI,
}
if _, err = a.conn.
NewInsert().
Model(acct).
@ -158,6 +159,7 @@ func (a *adminDB) NewSignup(ctx context.Context, username string, reason string,
if emailVerified {
u.ConfirmedAt = time.Now()
u.Email = email
u.UnconfirmedEmail = ""
}
if admin {