mirror of
https://github.com/zitadel/zitadel
synced 2024-11-23 11:12:21 +00:00
fix: add org member (#3599)
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
parent
9291269075
commit
a9f82529ab
@ -67,7 +67,7 @@ func StartCommands(es *eventstore.Eventstore,
|
||||
oidcEncryption crypto.EncryptionAlgorithm,
|
||||
) (repo *Commands, err error) {
|
||||
if externalDomain == "" {
|
||||
return nil, errors.ThrowInvalidArgument(nil, "COMMAND-Df21s", "not external domain specified")
|
||||
return nil, errors.ThrowInvalidArgument(nil, "COMMAND-Df21s", "no external domain specified")
|
||||
}
|
||||
repo = &Commands{
|
||||
eventstore: es,
|
||||
|
@ -25,7 +25,7 @@ func (c *Commands) AddOrgMemberCommand(a *org.Aggregate, userID string, roles ..
|
||||
return nil, errors.ThrowInvalidArgument(nil, "Org-4N8es", "Errors.Org.MemberInvalid")
|
||||
}
|
||||
return func(ctx context.Context, filter preparation.FilterToQueryReducer) ([]eventstore.Command, error) {
|
||||
if exists, err := ExistsUser(ctx, filter, userID, a.ID); err != nil || !exists {
|
||||
if exists, err := ExistsUser(ctx, filter, userID, ""); err != nil || !exists {
|
||||
return nil, errors.ThrowPreconditionFailed(err, "ORG-GoXOn", "Errors.User.NotFound")
|
||||
}
|
||||
if isMember, err := IsOrgMember(ctx, filter, a.ID, userID); err != nil || isMember {
|
||||
@ -73,7 +73,7 @@ func IsOrgMember(ctx context.Context, filter preparation.FilterToQueryReducer, o
|
||||
return isMember, nil
|
||||
}
|
||||
|
||||
func (c *Commands) AddOrgMember(ctx context.Context, userID, orgID string, roles ...string) (*domain.Member, error) {
|
||||
func (c *Commands) AddOrgMember(ctx context.Context, orgID, userID string, roles ...string) (*domain.Member, error) {
|
||||
orgAgg := org.NewAggregate(orgID)
|
||||
cmds, err := preparation.PrepareCommands(ctx, c.eventstore.Filter, c.AddOrgMemberCommand(orgAgg, userID, roles...))
|
||||
if err != nil {
|
||||
|
@ -519,7 +519,7 @@ func TestCommandSide_AddOrgMember(t *testing.T) {
|
||||
eventstore: tt.fields.eventstore,
|
||||
zitadelRoles: tt.fields.zitadelRoles,
|
||||
}
|
||||
got, err := r.AddOrgMember(tt.args.ctx, tt.args.userID, tt.args.orgID, tt.args.roles...)
|
||||
got, err := r.AddOrgMember(tt.args.ctx, tt.args.orgID, tt.args.userID, tt.args.roles...)
|
||||
if tt.res.err == nil {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user