Fixed duplicate path issue for kv engine (#11423)

- Ids used to collide in ember data while creating a secret with any existing
path name from a different kv engine
This commit is contained in:
Arnav Palnitkar 2021-04-20 12:11:21 -07:00 committed by GitHub
parent b7ed30afed
commit 45e2bfcad7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 2 deletions

View File

@ -199,6 +199,13 @@ export default Component.extend(FocusOnInsertMixin, WithNavToNearestAncestor, {
secretData.set(secretData.pathAttr, key);
}
if (this.mode === 'create') {
key = JSON.stringify({
backend: secret.backend,
id: key,
});
}
return secretData
.save()
.then(() => {
@ -323,8 +330,14 @@ export default Component.extend(FocusOnInsertMixin, WithNavToNearestAncestor, {
return;
}
this.persistKey(() => {
this.transitionToRoute(SHOW_ROUTE, this.model.path || this.model.id);
this.persistKey(key => {
let secretKey;
try {
secretKey = JSON.parse(key).id;
} catch (error) {
secretKey = key;
}
this.transitionToRoute(SHOW_ROUTE, secretKey);
});
},