Skip to content

Commit 3364f20

Browse files
committed
cleanup ispasswordchangerequired from user_view
1 parent 316c454 commit 3364f20

File tree

9 files changed

+19
-65
lines changed

9 files changed

+19
-65
lines changed

api/src/main/java/org/apache/cloudstack/api/command/admin/user/UpdateUserCmd.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,4 @@ public ApiCommandResourceType getApiResourceType() {
203203
public Boolean isPasswordChangeRequired() {
204204
return BooleanUtils.isTrue(passwordChangeRequired);
205205
}
206-
207-
public void setPasswordChangeRequired(Boolean passwordChangeRequired) {
208-
this.passwordChangeRequired = passwordChangeRequired;
209-
}
210206
}

api/src/main/java/org/apache/cloudstack/api/response/UserResponse.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,6 @@ public class UserResponse extends BaseResponse implements SetResourceIconRespons
132132
@Param(description = "whether api key access is Enabled, Disabled or set to Inherit (it inherits the value from the parent)", since = "4.20.1.0")
133133
ApiConstants.ApiKeyAccess apiKeyAccess;
134134

135-
@SerializedName(value = ApiConstants.PASSWORD_CHANGE_REQUIRED)
136-
@Param(description = "Indicates whether the User is required to change password on next login.", since = "4.23.0")
137-
private Boolean passwordChangeRequired;
138-
139135
@Override
140136
public String getObjectId() {
141137
return this.getId();
@@ -321,12 +317,4 @@ public void set2FAmandated(Boolean is2FAmandated) {
321317
public void setApiKeyAccess(Boolean apiKeyAccess) {
322318
this.apiKeyAccess = ApiConstants.ApiKeyAccess.fromBoolean(apiKeyAccess);
323319
}
324-
325-
public Boolean isPasswordChangeRequired() {
326-
return Boolean.TRUE.equals(passwordChangeRequired);
327-
}
328-
329-
public void setPasswordChangeRequired(Boolean passwordChangeRequired) {
330-
this.passwordChangeRequired = passwordChangeRequired;
331-
}
332320
}

engine/schema/src/main/resources/META-INF/db/views/cloud.user_view.sql

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ select
5353
async_job.uuid job_uuid,
5454
async_job.job_status job_status,
5555
async_job.account_id job_account_id,
56-
user.is_user_2fa_enabled is_user_2fa_enabled,
57-
`user_details`.`value` AS `password_change_required`
56+
user.is_user_2fa_enabled is_user_2fa_enabled
5857
from
5958
`cloud`.`user`
6059
inner join
@@ -64,7 +63,4 @@ from
6463
left join
6564
`cloud`.`async_job` ON async_job.instance_id = user.id
6665
and async_job.instance_type = 'User'
67-
and async_job.job_status = 0
68-
left join
69-
`cloud`.`user_details` AS `user_details` ON `user_details`.`user_id` = `user`.`id`
70-
and `user_details`.`name` = 'PasswordChangeRequired';
66+
and async_job.job_status = 0;

plugins/api/discovery/src/main/java/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public class ApiDiscoveryServiceImpl extends ComponentLifecycleBase implements A
6969
List<APIChecker> _apiAccessCheckers = null;
7070
List<PluggableService> _services = null;
7171
protected static Map<String, ApiDiscoveryResponse> s_apiNameDiscoveryResponseMap = null;
72-
public static final List<String> APIS_ALLOWED_FOR_PASSWORD_CHANGE = Arrays.asList("login", "logout", "updateUser", "listUsers", "listApis");
72+
public static final List<String> APIS_ALLOWED_FOR_PASSWORD_CHANGE = Arrays.asList("login", "logout", "updateUser", "listApis");
7373

7474
@Inject
7575
AccountService accountService;

plugins/api/discovery/src/test/java/org/apache/cloudstack/discovery/ApiDiscoveryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,6 @@ public void listApisForUserEnforcedPwdChange() throws PermissionDeniedException
167167
Mockito.when(roleServiceMock.findRole(Mockito.anyLong())).thenReturn(userRoleVO);
168168
Mockito.when(apiNameDiscoveryResponseMapMock.get(Mockito.anyString())).thenReturn(Mockito.mock(ApiDiscoveryResponse.class));
169169
ListResponse<ApiDiscoveryResponse> response = (ListResponse<ApiDiscoveryResponse>) discoveryServiceSpy.listApis(getTestUser(), null);
170-
Assert.assertEquals(5, response.getResponses().size());
170+
Assert.assertEquals(4, response.getResponses().size());
171171
}
172172
}

server/src/main/java/com/cloud/api/query/dao/UserAccountJoinDaoImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public UserResponse newUserResponse(ResponseView view, UserAccountJoinVO usr) {
7373
userResponse.setSecretKey(usr.getSecretKey());
7474
userResponse.setIsDefault(usr.isDefault());
7575
userResponse.set2FAenabled(usr.isUser2faEnabled());
76-
userResponse.setPasswordChangeRequired(usr.isPasswordChangeRequired());
7776
long domainId = usr.getDomainId();
7877
boolean is2FAmandated = Boolean.TRUE.equals(AccountManagerImpl.enableUserTwoFactorAuthentication.valueIn(domainId)) && Boolean.TRUE.equals(AccountManagerImpl.mandateUserTwoFactorAuthentication.valueIn(domainId));
7978
userResponse.set2FAmandated(is2FAmandated);

server/src/main/java/com/cloud/api/query/vo/UserAccountJoinVO.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,6 @@ public class UserAccountJoinVO extends BaseViewVO implements InternalIdentity, I
136136
@Column(name = "api_key_access")
137137
Boolean apiKeyAccess;
138138

139-
@Column(name = "password_change_required")
140-
Boolean passwordChangeRequired;
141-
142139
public UserAccountJoinVO() {
143140
}
144141

@@ -291,8 +288,4 @@ public boolean isUser2faEnabled() {
291288
public Boolean getApiKeyAccess() {
292289
return apiKeyAccess;
293290
}
294-
295-
public Boolean isPasswordChangeRequired() {
296-
return passwordChangeRequired;
297-
}
298291
}

ui/src/store/modules/user.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -345,15 +345,7 @@ const user = {
345345
const isPwdChangeRequired = vueProps.$localStorage.get(PASSWORD_CHANGE_REQUIRED)
346346
commit('SET_PASSWORD_CHANGE_REQUIRED', isPwdChangeRequired)
347347
if (isPwdChangeRequired) {
348-
getAPI('listUsers', { id: Cookies.get('userid') }).then(response => {
349-
const result = response.listusersresponse.user[0]
350-
commit('SET_INFO', result)
351-
commit('SET_NAME', result.firstname + ' ' + result.lastname)
352-
if (result.icon?.base64image) commit('SET_AVATAR', result.icon.base64image)
353-
resolve({})
354-
}).catch(error => {
355-
reject(error)
356-
})
348+
resolve()
357349
return
358350
}
359351

ui/src/views/iam/ForceChangePassword.vue

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
type="primary"
4242
size="large"
4343
block
44-
@click="handleLogout"
44+
@click="redirectToLogin()"
4545
style="margin-top: 20px;"
4646
>
4747
{{ $t('label.login') }}
@@ -95,7 +95,7 @@
9595
</a-form-item>
9696

9797
<div class="actions">
98-
<a @click="handleLogout">{{ $t('label.logout') }}</a>
98+
<a @click="logoutAndRedirectToLogin()">{{ $t('label.logout') }}</a>
9999
</div>
100100
</a-form>
101101
</a-spin>
@@ -167,7 +167,8 @@ export default {
167167
currentpassword: values.currentpassword
168168
}
169169
postAPI('updateUser', params).then(() => {
170-
this.$message.success(this.$t('message.please.login.new.password'))
170+
this.$localStorage.remove(PASSWORD_CHANGE_REQUIRED)
171+
this.handleLogout()
171172
this.isSubmitted = true
172173
}).catch(error => {
173174
console.error(error)
@@ -187,30 +188,19 @@ export default {
187188
} finally {
188189
Cookies.remove('userid')
189190
Cookies.remove('token')
190-
this.$localStorage.remove(PASSWORD_CHANGE_REQUIRED)
191-
this.$router.replace({ path: '/user/login' })
192191
}
193192
},
194-
async isPasswordChangeRequired () {
195-
try {
196-
this.loading = true
197-
const user = await this.getUserInfo()
198-
if (user && !user.passwordchangerequired) {
199-
this.isSubmitted = true
200-
}
201-
} catch (e) {
202-
console.error('Failed to resolve user info:', e)
203-
} finally {
204-
this.loading = false
205-
}
193+
redirectToLogin () {
194+
this.$router.replace('/user/login')
206195
},
207-
async getUserInfo () {
208-
const userInfo = this.$store.getters.userInfo
209-
if (userInfo && userInfo.id) {
210-
return userInfo
211-
}
212-
await this.$store.dispatch('GetInfo')
213-
return this.$store.getters.userInfo
196+
logoutAndRedirectToLogin () {
197+
this.handleLogout().then(() => {
198+
this.redirectToLogin()
199+
})
200+
},
201+
async isPasswordChangeRequired () {
202+
const passwordChangeRequired = this.$localStorage.get(PASSWORD_CHANGE_REQUIRED)
203+
this.isSubmitted = !passwordChangeRequired
214204
}
215205
}
216206
}

0 commit comments

Comments
 (0)