Skip to content

Commit

Permalink
fix FindAccount bug when attempting operationAppSignUp
Browse files Browse the repository at this point in the history
  • Loading branch information
roberlander2 committed Mar 7, 2024
1 parent 3b19c8b commit be0cb54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions core/auth/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ func (a *Auth) CreateAdminAccount(authenticationType string, appID string, orgID

transaction := func(context storage.TransactionContext) error {
//1. find the account for the org and the user identity
account, err := a.storage.FindAccount(context, identifierImpl.getCode(), identifier, &appOrg.ID, &appOrg.Organization.ID)
account, err := a.storage.FindAccount(context, identifierImpl.getCode(), identifier, &appOrg.ID, nil) // do not provide an appOrgID because we want to know if there is an account in the organization with the same identifier
if err != nil {
return errors.WrapErrorAction(logutils.ActionFind, model.TypeAccount, nil, err)
}
Expand Down Expand Up @@ -782,7 +782,7 @@ func (a *Auth) CreateAccounts(partialAccount []model.AccountData, creatorPermiss

// create account
//find the account for the org and the user identity
foundedAccount, err := a.storage.FindAccount(context, identifierImpl.getCode(), identifier, &appOrg.ID, &appOrg.Organization.ID)
foundedAccount, err := a.storage.FindAccount(context, identifierImpl.getCode(), identifier, &appOrg.ID, nil) // do not provide an appOrgID because we want to know if there is an account in the organization with the same identifier
if err != nil {
return errors.WrapErrorAction(logutils.ActionFind, model.TypeAccount, nil, err)
}
Expand Down
6 changes: 3 additions & 3 deletions core/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func (a *Auth) applyExternalAuthType(supportedAuthType model.SupportedAuthType,
code = IdentifierTypeEmail
}

account, err := a.storage.FindAccount(nil, code, externalUser.Identifier, &appOrg.Organization.ID, &appOrg.ID)
account, err := a.storage.FindAccount(nil, code, externalUser.Identifier, &appOrg.Organization.ID, nil) // do not provide an appOrgID because we want to know if there is an account in the organization with the same identifier
if err != nil {
return nil, nil, nil, errors.WrapErrorAction(logutils.ActionFind, model.TypeAccount, nil, err)
}
Expand Down Expand Up @@ -646,7 +646,7 @@ func (a *Auth) applyAuthType(supportedAuthType model.SupportedAuthType, appOrg m
var account *model.Account
appOrgID := &appOrg.ID
if identifierImpl == nil {
// if given an account identifier ID, find the account and attempt sign in
// if given an account identifier ID, find the account and attempt sign in (operationSignIn)
if accountIdentifierID != nil {
account, err = a.storage.FindAccountByIdentifierID(nil, *accountIdentifierID, appOrgID)
if err != nil {
Expand Down Expand Up @@ -692,7 +692,7 @@ func (a *Auth) applyAuthType(supportedAuthType model.SupportedAuthType, appOrg m
code := identifierImpl.getCode()
identifier := identifierImpl.getIdentifier()
//find the account for the org and the user identity
account, err = a.storage.FindAccount(nil, code, identifier, &appOrg.Organization.ID, appOrgID)
account, err = a.storage.FindAccount(nil, code, identifier, &appOrg.Organization.ID, nil) // do not provide an appOrgID because we want to know if there is an account in the organization with the same identifier
if err != nil {
return nil, nil, nil, errors.WrapErrorAction(logutils.ActionFind, model.TypeAccount, &logutils.FieldArgs{"app_org_id": appOrg.ID, "code": code, "identifier": identifier}, err)
}
Expand Down

0 comments on commit be0cb54

Please sign in to comment.