From 18e7537393492953882a80aa1468800fa122edea Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Mon, 31 Jan 2022 16:03:47 +0100 Subject: [bug] Fix OIDC users requiring second approval (#371) * tidy up NewSignup * pre-approve users created via OIDC --- internal/db/bundb/admin.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'internal/db/bundb/admin.go') diff --git a/internal/db/bundb/admin.go b/internal/db/bundb/admin.go index 37c0db6d3..a92834f9c 100644 --- a/internal/db/bundb/admin.go +++ b/internal/db/bundb/admin.go @@ -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 := >smodel.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 { -- cgit v1.2.3