Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pci-object-storage): secret key not displayed #14231

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import controller from './controller';
const component = {
bindings: {
isDisplayableShowHidePasswordBtn: '<',
fieldId: '<',
fieldId: '@',
fieldKeyLabel: '<',
fieldKeyValue: '<',
onCopyClick: '&',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ export default class CreateLinkedUserController {
$translate,
CucCloudMessage,
PciStoragesUsersService,
PciStoragesObjectStorageService,
atInternet,
$scope,
) {
this.$q = $q;
this.$translate = $translate;
this.CucCloudMessage = CucCloudMessage;
this.PciStoragesUsersService = PciStoragesUsersService;
this.PciStoragesObjectStorageService = PciStoragesObjectStorageService;
this.atInternet = atInternet;
this.$scope = $scope;
}

$onInit() {
Expand Down Expand Up @@ -176,32 +180,47 @@ export default class CreateLinkedUserController {
this.userModel.createOrLinkedMode = CONTAINER_USER_ASSOCIATION_MODES.CREATE;
}

onLinkedUserClicked() {
async onLinkedUserClicked() {
this.trackClick(`${TRACKING_ASSOCIATE_USER}-confirm`);

const service = this.PciStoragesUsersService;
const { selected: user } = this.userModel.linkedMode;
const defaultCredential = user.s3Credentials;
const functionToCallPromise = defaultCredential
const service = this.PciStoragesUsersService;

const credentialPromise = user.s3Credentials
? service.getS3Credential(
this.projectId,
user.id,
defaultCredential.access,
user.s3Credentials.access,
)
: service.generateS3Credential(this.projectId, user.id);

const secretPromise = this.PciStoragesObjectStorageService.getS3Secret(
this.projectId,
user.id,
user.s3Credentials?.access,
);

this.userModel.linkedMode.isInProgress = true;

return functionToCallPromise
.then((credential) => {
return Promise.all([credentialPromise, secretPromise])
.then(([credential, secretData]) => {
this.trackPage(`${TRACKING_ASSOCIATE_USER}-success`);

user.s3Credentials = credential;
this.userModel.linkedMode.credential = credential;
this.userModel.linkedMode.credential = {
...credential,
secret: secretData.secret,
};
})
.catch(() => {
this.trackPage(`${TRACKING_ASSOCIATE_USER}-error`);
})
.finally(() => {
this.userModel.linkedMode.isInProgress = false;

// Ensure the final state updates trigger a digest cycle
if (!this.$scope.$$phase) {
this.$scope.$apply();
}
});
}

Expand Down
Loading