better api error codes from OIDC auth method update/change-state operations (#1116)

pull/1120/head^2
Jim 5 years ago committed by GitHub
parent ba693bbafc
commit e0e6e58bb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -239,7 +239,12 @@ func (s Service) UpdateAuthMethod(ctx context.Context, req *pbs.UpdateAuthMethod
}
u, err := s.updateInRepo(ctx, authResults.Scope.GetId(), req)
if err != nil {
return nil, err
switch {
case errors.Match(errors.T(errors.InvalidParameter), err):
return nil, handlers.ApiErrorWithCodeAndMessage(codes.InvalidArgument, "Unable to update auth method: %v.", err)
default:
return nil, err
}
}
u.Scope = authResults.Scope
u.AuthorizedActions = authResults.FetchActionSetForId(ctx, u.Id, IdActions[auth.SubtypeFromId(u.Id)]).Strings()
@ -260,7 +265,12 @@ func (s Service) ChangeState(ctx context.Context, req *pbs.ChangeStateRequest) (
}
am, err := s.changeStateInRepo(ctx, req)
if err != nil {
return nil, err
switch {
case errors.Match(errors.T(errors.InvalidParameter), err):
return nil, handlers.ApiErrorWithCodeAndMessage(codes.InvalidArgument, "Unable to change auth method state: %v.", err)
default:
return nil, err
}
}
am.Scope = authResults.Scope
am.AuthorizedActions = authResults.FetchActionSetForId(ctx, am.Id, IdActions[auth.OidcSubtype]).Strings()

Loading…
Cancel
Save