backport of UI: handle control group error on SSH (#23034)

Co-authored-by: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com>
This commit is contained in:
hc-github-team-secure-vault-core 2023-09-20 12:18:57 -04:00 committed by GitHub
parent 3ba22f14e0
commit 3505868165
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 4 deletions

3
changelog/23025.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
ui (enterprise): Fix error message when generating SSH credential with control group
```

View File

@ -31,6 +31,7 @@ const MODEL_TYPES = {
};
export default Component.extend({
controlGroup: service(),
store: service(),
router: service(),
// set on the component
@ -95,8 +96,21 @@ export default Component.extend({
create() {
const model = this.model;
this.set('loading', true);
this.model.save().finally(() => {
this.model
.save()
.then(() => {
model.set('hasGenerated', true);
})
.catch((error) => {
// Handle control group AdapterError
if (error.message === 'Control Group encountered') {
this.controlGroup.saveTokenFromError(error);
const err = this.controlGroup.logFromError(error);
error.errors = [err.content];
}
throw error;
})
.finally(() => {
this.set('loading', false);
});
},