Skip to content

Commit 44306a2

Browse files
yoshiemuranakarfrandse
authored andcommitted
Add local user account manual unlock
Adds ability to manually unlock user account if account service settings lockout duration set to 0. Signed-off-by: Yoshie Muranaka <[email protected]> Change-Id: I75351c5e03bd5403e8dc7679d8d98b90adb90277
1 parent f2726a2 commit 44306a2

File tree

4 files changed

+57
-6
lines changed

4 files changed

+57
-6
lines changed

src/components/Global/Alert.vue

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<b-alert :show="show" :variant="variant">
2+
<b-alert :show="show" :variant="variant" :class="{ small }">
33
<div v-if="variant == 'warning' || variant == 'danger'" class="alert-icon">
44
<status-icon :status="variant" />
55
</div>
@@ -27,7 +27,15 @@ export default {
2727
variant: {
2828
type: String,
2929
default: ''
30-
}
30+
},
31+
small: Boolean
3132
}
3233
};
3334
</script>
35+
36+
<style lang="scss" scoped>
37+
.alert.small {
38+
padding: $spacer / 2;
39+
font-size: 1rem;
40+
}
41+
</style>

src/locales/en-US.json

+3
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@
8585
"editUser": "Edit user",
8686
"viewPrivilegeRoleDescriptions": "View privilege role descriptions",
8787
"modal": {
88+
"accountLocked": "Account locked",
8889
"accountStatus": "Account status",
8990
"automaticAfterTimeout": "Automatic after timeout",
9091
"cannotStartWithANumber": "Cannot start with a number",
92+
"clickSaveToUnlockAccount": "Click \"Save\" to unlock account",
9193
"confirmUserPassword": "Confirm user password",
9294
"deleteConfirmMessage": "Are you sure you want to delete user '%{user}'? This action cannot be undone.",
9395
"manual": "Manual",
@@ -97,6 +99,7 @@
9799
"passwordsDoNotMatch": "Passwords do not match",
98100
"privilege": "Privilege",
99101
"timeoutDurationSeconds": "Timeout duration (seconds)",
102+
"unlock": "Unlock",
100103
"username": "Username",
101104
"userPassword": "User password",
102105
"userUnlockMethod": "User unlock method"

src/store/modules/AccessControl/LocalUserMangementStore.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,14 @@ const LocalUserManagementStore = {
106106
},
107107
async updateUser(
108108
{ dispatch },
109-
{ originalUsername, username, password, privilege, status }
109+
{ originalUsername, username, password, privilege, status, locked }
110110
) {
111111
const data = {};
112112
if (username) data.UserName = username;
113113
if (password) data.Password = password;
114114
if (privilege) data.RoleId = privilege;
115115
if (status !== undefined) data.Enabled = status;
116+
if (locked !== undefined) data.Locked = locked;
116117
return await api
117118
.patch(`/redfish/v1/AccountService/Accounts/${originalUsername}`, data)
118119
.then(() => dispatch('getUsers'))

src/views/AccessControl/LocalUserManagement/ModalUser.vue

+42-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,31 @@
1010
</template>
1111
<b-form novalidate @submit="handleSubmit">
1212
<b-container>
13+
<!-- Manual unlock form control -->
14+
<b-row v-if="!newUser && manualUnlockPolicy && user.Locked">
15+
<b-col sm="9">
16+
<alert :show="true" variant="warning" small>
17+
<template v-if="!$v.form.manualUnlock.$dirty">
18+
{{ $t('pageLocalUserManagement.modal.accountLocked') }}
19+
</template>
20+
<template v-else>
21+
{{
22+
$t('pageLocalUserManagement.modal.clickSaveToUnlockAccount')
23+
}}
24+
</template>
25+
</alert>
26+
</b-col>
27+
<b-col sm="3">
28+
<input v-model="form.manualUnlock" type="hidden" value="false" />
29+
<b-button
30+
variant="primary"
31+
:disabled="$v.form.manualUnlock.$dirty"
32+
@click="$v.form.manualUnlock.$touch()"
33+
>
34+
{{ $t('pageLocalUserManagement.modal.unlock') }}
35+
</b-button>
36+
</b-col>
37+
</b-row>
1338
<b-row>
1439
<b-col>
1540
<b-form-group
@@ -183,9 +208,10 @@ import {
183208
} from 'vuelidate/lib/validators';
184209
import VuelidateMixin from '../../../components/Mixins/VuelidateMixin.js';
185210
import InputPasswordToggle from '../../../components/Global/InputPasswordToggle';
211+
import Alert from '../../../components/Global/Alert';
186212
187213
export default {
188-
components: { InputPasswordToggle },
214+
components: { Alert, InputPasswordToggle },
189215
mixins: [VuelidateMixin],
190216
props: {
191217
user: {
@@ -206,13 +232,20 @@ export default {
206232
username: '',
207233
privilege: '',
208234
password: '',
209-
passwordConfirmation: ''
235+
passwordConfirmation: '',
236+
manualUnlock: false
210237
}
211238
};
212239
},
213240
computed: {
214241
newUser() {
215242
return this.user ? false : true;
243+
},
244+
accountSettings() {
245+
return this.$store.getters['localUsers/accountSettings'];
246+
},
247+
manualUnlockPolicy() {
248+
return !this.accountSettings.accountLockoutDuration;
216249
}
217250
},
218251
watch: {
@@ -250,7 +283,8 @@ export default {
250283
return this.requirePassword();
251284
}),
252285
sameAsPassword: sameAs('password')
253-
}
286+
},
287+
manualUnlock: {}
254288
}
255289
};
256290
},
@@ -280,6 +314,11 @@ export default {
280314
if (this.$v.form.password.$dirty) {
281315
userData.password = this.form.password;
282316
}
317+
if (this.$v.form.manualUnlock.$dirty) {
318+
// If form manualUnlock control $dirty then
319+
// set user Locked property to false
320+
userData.locked = false;
321+
}
283322
if (Object.entries(userData).length === 1) {
284323
this.closeModal();
285324
return;

0 commit comments

Comments
 (0)