Skip to content

Commit

Permalink
Allow invites with user-endpoints (#4876)
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Quandt <thquad@gmail.com>
  • Loading branch information
thquad authored and richard-cox committed Apr 16, 2021
1 parent 59a1daa commit f3d0e39
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ export class UserInviteService {
]).pipe(
map(([cf, auth, endpoint]) =>
cf.global.isAdmin &&
auth.sessionData['plugin-config'] && auth.sessionData['plugin-config'].userInvitationsEnabled === 'true' &&
endpoint.entity.creator.admin)
auth.sessionData['plugin-config'] && auth.sessionData['plugin-config'].userInvitationsEnabled === 'true')
);
}

Expand Down
5 changes: 0 additions & 5 deletions src/jetstream/plugins/userinvite/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ func (invite *UserInvite) configure(c echo.Context) error {
)
}

_, err := invite.checkEndpointCreator(cfGUID, c)
if err != nil {
return err
}

uaaRecord, _, err := invite.RefreshToken(cfGUID, clientID, clientSecret)
if err != nil {
return err
Expand Down
22 changes: 0 additions & 22 deletions src/jetstream/plugins/userinvite/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,28 +119,6 @@ func (invite *UserInvite) refreshToken(clientID, clientSecret string, endpoint i
return &uaaResponse, tokenRecord, nil
}

// Check that there is an endpoint with the specified ID and if the creator is an admin
func (invite *UserInvite) checkEndpointCreator(cfGUID string, c echo.Context) (interfaces.CNSIRecord, error) {
endpoint, err := invite.portalProxy.GetCNSIRecord(cfGUID)
if err != nil {
return interfaces.CNSIRecord{}, interfaces.NewHTTPShadowError(
http.StatusBadRequest,
"Can not find enpoint",
"Can not find enpoint: %s", cfGUID,
)
}

if len(endpoint.Creator) != 0 {
return interfaces.CNSIRecord{}, interfaces.NewHTTPShadowError(
http.StatusBadRequest,
"Not an admin endpoint",
"Not an admin endpoint: %s", cfGUID,
)
}

return endpoint, nil
}

func (invite *UserInvite) checkEndpoint(cfGUID string) (interfaces.CNSIRecord, error) {
// Check that there is an endpoint with the specified ID and that it is a Cloud Foundry endpoint
endpoint, err := invite.portalProxy.GetCNSIRecord(cfGUID)
Expand Down

0 comments on commit f3d0e39

Please sign in to comment.