Skip to content

Commit 4bf90ce

Browse files
css and change password fixes
1 parent 2b60e4c commit 4bf90ce

File tree

5 files changed

+78
-53
lines changed

5 files changed

+78
-53
lines changed

src/store/modules/SecurityAndAccess/UserManagementStore.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export const UserManagementStore = defineStore('userManagment', {
5858
return await api
5959
.all(userIds.map((user) => api.get(user)))
6060
.then((users) => {
61-
console.log('then called', users);
6261
const userData = users.map((user) => user.data);
6362
this.allUsers = userData;
6463
this.allUsers.map((user) => {
@@ -75,9 +74,17 @@ export const UserManagementStore = defineStore('userManagment', {
7574
})
7675
.catch((error) => {
7776
console.log(error);
78-
const message = i18n.global.t(
79-
'pageUserManagement.toast.errorLoadUsers',
80-
);
77+
let message = '';
78+
if (
79+
error.response.data['@Message.ExtendedInfo'] &&
80+
error.response.data['@Message.ExtendedInfo'][0].MessageId.endsWith(
81+
'GenerateSecretKeyRequired',
82+
)
83+
) {
84+
message = 'otpRequired';
85+
} else {
86+
message = i18n.global.t('pageUserManagement.toast.errorLoadUsers');
87+
}
8188
throw new Error(message);
8289
});
8390
},
@@ -233,7 +240,6 @@ export const UserManagementStore = defineStore('userManagment', {
233240
if (locked !== undefined) data.Locked = locked;
234241
return await api
235242
.patch(`/redfish/v1/AccountService/Accounts/${originalUsername}`, data)
236-
.then(() => this.getUsers())
237243
.then(() =>
238244
i18n.global.t('pageUserManagement.toast.successUpdateUser', {
239245
username: originalUsername,

src/views/ChangePassword/ChangePassword.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
</b-button>
7979
</div>
8080
</b-form>
81+
<modal-otp-generate />
8182
</div>
8283
</div>
8384
</template>
@@ -92,6 +93,8 @@ import Alert from '@/components/Global/Alert.vue';
9293
import InfoTooltipPassword from '@/components/Global/InfoTooltipPassword.vue';
9394
import InputPasswordToggle from '@/components/Global/InputPasswordToggle.vue';
9495
import { useRouter } from 'vue-router';
96+
import ModalOtpGenerate from '../Login/ModalOtpGenerate.vue';
97+
import eventBus from '@/eventBus';
9598
9699
const global = stores.GlobalStore();
97100
const userManagementStore = stores.UserManagementStore();
@@ -141,10 +144,19 @@ const changePassword = () => {
141144
userManagementStore.getUsers(),
142145
global.getCurrentUser(username.value),
143146
global.getSystemInfo(),
144-
]);
147+
])
148+
.then(() => router.push('/'))
149+
.catch((error) => {
150+
if (error?.message?.endsWith('otpRequired')) {
151+
userManagementStore.clearSecretKey().finally(() => {
152+
userManagementStore.generateSecretKey().then(() => {
153+
eventBus.emit('otp-generate-modal');
154+
});
155+
});
156+
}
157+
});
145158
v$.value.$reset();
146159
})
147-
.then(() => router.push('/'))
148160
.catch(() => (changePasswordError.value = true));
149161
};
150162
const updatePasswordType = (passwordType) => {

src/views/Login/ModalOtpGenerate.vue

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
>
1717
<b-row>
1818
<b-col>
19-
<b-row>
19+
<div class="qr-wrapper">
2020
<qrcode-vue
2121
v-if="qrValue"
2222
class="qrcode-styling"
@@ -26,9 +26,9 @@
2626
render-as="canvas"
2727
/>
2828
<div v-else class="emptyQrStyle"></div>
29-
</b-row>
30-
<b-row>
31-
<b-col>
29+
</div>
30+
<div class="secret-key-buttons-container">
31+
<div>
3232
<b-button
3333
v-b-toggle.collapse-2
3434
class="m-1 buttonStyle"
@@ -40,18 +40,16 @@
4040
<b-collapse id="collapse-2" data-test-id="modal-secret-key-value">
4141
{{ dataFormatter(secretKey) }}
4242
</b-collapse>
43-
</b-col>
44-
<b-col class="m-1">
45-
<b-button @click="copySecretKey">
46-
<template v-if="secretKeyCopied">
47-
<icon-checkmark title="Copied" />
48-
</template>
49-
<template v-else>
50-
<icon-copy title="Copy Secret key" />
51-
</template>
52-
</b-button>
53-
</b-col>
54-
</b-row>
43+
</div>
44+
<b-button class="m-1" @click="copySecretKey">
45+
<template v-if="secretKeyCopied">
46+
<icon-checkmark title="Copied" />
47+
</template>
48+
<template v-else>
49+
<icon-copy title="Copy Secret key" />
50+
</template>
51+
</b-button>
52+
</div>
5553
</b-col>
5654
<b-col>
5755
<b-form
@@ -134,7 +132,7 @@ const accountName = ref(localStorage.getItem('storedUsername'));
134132
const otpValue = ref(null);
135133
const secretKeyCopied = ref(false);
136134
const qrValue = ref(null);
137-
const size = ref(350);
135+
const size = ref(355);
138136
const { errorToast } = useToast();
139137
140138
const globalStore = GlobalStore();
@@ -215,14 +213,18 @@ function handleSubmit() {
215213
}
216214
function closeModal() {
217215
nextTick(() => {
216+
v$.value.$reset();
218217
modal.value = false;
219218
});
220219
}
221220
</script>
222221
<style lang="scss" scoped>
223222
.qrcode-styling {
224223
margin-left: 15px;
225-
max-width: 350px;
224+
}
225+
226+
.qr-wrapper {
227+
max-width: none !important;
226228
}
227229
.row {
228230
margin-left: 0px;
@@ -246,4 +248,8 @@ function closeModal() {
246248
transform: rotate(180deg);
247249
}
248250
}
251+
.secret-key-buttons-container {
252+
display: flex;
253+
justify-content: space-between;
254+
}
249255
</style>

src/views/SecurityAndAccess/UserManagement/RegisterOtpModal.vue

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
>
1717
<b-row>
1818
<b-col>
19-
<b-row>
19+
<div class="qr-wrapper">
2020
<qrcode-vue
2121
v-if="qrValue"
2222
class="qrcode-styling"
@@ -26,9 +26,9 @@
2626
render-as="canvas"
2727
/>
2828
<div v-else class="emptyQrStyle"></div>
29-
</b-row>
30-
<b-row>
31-
<b-col>
29+
</div>
30+
<div class="secret-key-buttons-container">
31+
<div>
3232
<b-button
3333
v-b-toggle.collapse-2
3434
class="m-1 buttonStyle"
@@ -40,18 +40,16 @@
4040
<b-collapse id="collapse-2" data-test-id="secret-key-value">
4141
{{ dataFormatter(secretKey) }}
4242
</b-collapse>
43-
</b-col>
44-
<b-col class="m-1">
45-
<b-button @click="copySecretKey">
43+
</div>
44+
<b-button class="m-1" @click="copySecretKey">
4645
<template v-if="secretKeyCopied">
4746
<icon-checkmark title="Copied" />
4847
</template>
4948
<template v-else>
5049
<icon-copy title="Copy Secret key" />
5150
</template>
5251
</b-button>
53-
</b-col>
54-
</b-row>
52+
</div>
5553
</b-col>
5654
<b-col>
5755
<b-form
@@ -151,7 +149,7 @@ const accountName = ref(localStorage.getItem('storedUsername'));
151149
const otpValue = ref(null);
152150
const secretKeyCopied = ref(false);
153151
const qrValue = ref(null);
154-
const size = ref(350);
152+
const size = ref(355);
155153
156154
const { errorToast, successToast } = useToast();
157155
@@ -187,16 +185,14 @@ const secretKey = computed(() => {
187185
return userManagementStore.secretKeyInfoGetter;
188186
});
189187
190-
watch(secretKey,(newValue) => {
191-
globalStore.getBmcTime();
192-
if (newValue === null) {
193-
qrValue.value = null;
194-
} else {
195-
qrValue.value = `otpauth://totp/${issuer.value}:${accountName.value}?secret=${newValue}&issuer=${issuer.value}`;
196-
}
197-
},
198-
);
199-
188+
watch(secretKey, (newValue) => {
189+
globalStore.getBmcTime();
190+
if (newValue === null) {
191+
qrValue.value = null;
192+
} else {
193+
qrValue.value = `otpauth://totp/${issuer.value}:${accountName.value}?secret=${newValue}&issuer=${issuer.value}`;
194+
}
195+
});
200196
201197
const rules = computed(() => ({
202198
otpValue: modal.value
@@ -208,7 +204,6 @@ const rules = computed(() => ({
208204
209205
const v$ = useVuelidate(rules, { otpValue });
210206
211-
212207
function copySecretKey() {
213208
navigator.clipboard.writeText(secretKey.value).then(() => {
214209
// Show copied text for 5 seconds
@@ -268,7 +263,9 @@ function closeModal() {
268263
<style lang="scss" scoped>
269264
.qrcode-styling {
270265
margin-left: 15px;
271-
max-width: 350px;
266+
}
267+
.qr-wrapper {
268+
max-width: none !important;
272269
}
273270
.row {
274271
margin-left: 0px;
@@ -291,4 +288,9 @@ function closeModal() {
291288
transform: rotate(180deg);
292289
}
293290
}
291+
292+
.secret-key-buttons-container {
293+
display: flex;
294+
justify-content: space-between;
295+
}
294296
</style>

src/views/SecurityAndAccess/UserManagement/UserManagement.vue

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
switch
2121
data-test-id="global-mfa"
2222
class="mt-1"
23-
@change="updateGlobalMfa"
23+
@update:model-value="updateGlobalMfa"
2424
>
2525
<span v-if="globalMfaValue">
2626
{{ $t('global.status.enabled') }}
@@ -374,10 +374,10 @@ const isServiceUser = computed(() => {
374374
375375
const globalMfaValue = computed({
376376
get() {
377-
return userManagement.isGlobalMfaEnabled;
377+
return userManagement.isGlobalMfaEnabledGetter;
378378
},
379379
set(newValue) {
380-
return userManagement.isGlobalMfaEnabled=newValue;
380+
return (userManagement.isGlobalMfaEnabled = newValue);
381381
},
382382
});
383383
@@ -433,7 +433,6 @@ watch(allUsers, (users) => {
433433
}));
434434
});
435435
436-
437436
const settings = computed(() => {
438437
return userManagement.accountSettingsGetter;
439438
});
@@ -512,14 +511,14 @@ function clearSecretKey(value) {
512511
}
513512
514513
function disableMFA() {
515-
globalMfaRef.value.checked = false;
514+
globalMfaValue.value = false;
516515
}
517516
518517
async function updateGlobalMfa(state) {
519518
await userManagement.checkCurrentUserMfaBypassed({
520519
uri: currentUser.value['@odata.id'],
521520
});
522-
if (!globalMfaValue.value) {
521+
if (globalMfaValue.value) {
523522
beforeMfa.value = true;
524523
userManagement
525524
.clearSecretKey()

0 commit comments

Comments
 (0)