satellite/console: remove need for nolint
Change-Id: I1b7ab00720f630c4ad3f984adc5698b41368613b
This commit is contained in:
parent
65408db6e0
commit
ce7adc8d85
@ -1499,25 +1499,34 @@ func (s *Service) isProjectOwner(ctx context.Context, userID uuid.UUID, projectI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// isProjectMember checks if the user is a member of given project.
|
// isProjectMember checks if the user is a member of given project.
|
||||||
func (s *Service) isProjectMember(ctx context.Context, userID uuid.UUID, projectID uuid.UUID) (result isProjectMember, err error) {
|
func (s *Service) isProjectMember(ctx context.Context, userID uuid.UUID, projectID uuid.UUID) (_ isProjectMember, err error) {
|
||||||
defer mon.Task()(&ctx)(&err)
|
defer mon.Task()(&ctx)(&err)
|
||||||
project, err := s.store.Projects().Get(ctx, projectID)
|
project, err := s.store.Projects().Get(ctx, projectID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, Error.Wrap(err)
|
return isProjectMember{}, Error.Wrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
memberships, err := s.store.ProjectMembers().GetByMemberID(ctx, userID)
|
memberships, err := s.store.ProjectMembers().GetByMemberID(ctx, userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, Error.Wrap(err)
|
return isProjectMember{}, Error.Wrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, membership := range memberships {
|
membership, ok := findMembershipByProjectID(memberships, projectID)
|
||||||
if membership.ProjectID == projectID {
|
if ok {
|
||||||
result.membership = &membership // nolint: scopelint
|
return isProjectMember{
|
||||||
result.project = project
|
project: project,
|
||||||
return
|
membership: &membership,
|
||||||
}
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return isProjectMember{}, ErrNoMembership.New(unauthorizedErrMsg)
|
return isProjectMember{}, ErrNoMembership.New(unauthorizedErrMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func findMembershipByProjectID(memberships []ProjectMember, projectID uuid.UUID) (ProjectMember, bool) {
|
||||||
|
for _, membership := range memberships {
|
||||||
|
if membership.ProjectID == projectID {
|
||||||
|
return membership, true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ProjectMember{}, false
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user