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

fix(user-account-page): apply changed planning (password-check, set mfa) #5568

Merged
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 @@ -18,8 +18,6 @@ import { useUserStore } from '@/store/user/user-store';

import { postValidationMfaCode } from '@/lib/helper/multi-factor-auth-helper';

import ErrorHandler from '@/common/composables/error/errorHandler';

import UserAccountMultiFactorAuthModalEmailInfo from '@/services/my-page/components/UserAccountMultiFactorAuthModalEmailInfo.vue';
import UserAccountMultiFactorAuthModalFolding from '@/services/my-page/components/UserAccountMultiFactorAuthModalFolding.vue';
import UserAccountMultiFactorAuthModalMSInfo
Expand Down Expand Up @@ -90,13 +88,6 @@ const handleChangeInput = (value: string) => {
};
const handleClickCancel = async () => {
resetFormData();
if (storeState.userId === state.userInfo.user_id) {
try {
await userStore.updateUser(state.userInfo);
} catch (e: any) {
ErrorHandler.handleError(e);
}
}
if (storeState.isSwitchModal && state.otherType) {
multiFactorAuthStore.setEnableMfaMap({
[storeState.selectedType]: true,
Expand All @@ -112,11 +103,8 @@ const handleClickVerifyButton = async () => {
state.userInfo = await postValidationMfaCode({
verify_code: validationState.verificationCode,
}) as UserInfoType;
if (storeState.userId === state.userInfo.user_id) {
await userStore.updateUser(state.userInfo);
if (state.userInfo.mfa) {
userStore.setMfa(state.userInfo.mfa);
}
if (storeState.userId === state.userInfo.user_id && state.userInfo.mfa) {
userStore.setMfa(state.userInfo.mfa);
}
resetFormData();
if (storeState.isReSyncModal || storeState.isSwitchModal) {
Expand Down
29 changes: 10 additions & 19 deletions apps/web/src/services/my-page/pages/UserAccountPage.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<script setup lang="ts">
import { computed, reactive } from 'vue';

import { debounce } from 'lodash';

import { SpaceConnector } from '@cloudforet/core-lib/space-connector';
import { getCancellableFetcher } from '@cloudforet/core-lib/space-connector/cancellable-fetcher';
import {
Expand All @@ -25,6 +23,7 @@ import { useDomainStore } from '@/store/domain/domain-store';
import { useUserStore } from '@/store/user/user-store';

import config from '@/lib/config';
import { showSuccessMessage } from '@/lib/helper/notice-alert-helper';

import UserAccountBaseInformation from '@/services/my-page/components/UserAccountBaseInformation.vue';
import UserAccountChangePassword from '@/services/my-page/components/UserAccountChangePassword.vue';
Expand Down Expand Up @@ -60,12 +59,11 @@ const state = reactive({
}),
readonlyMode: computed(() => {
const isLocalUser = storeState.authType === 'LOCAL';
return isLocalUser ? !passwordFormState.isPasswordChecked : false;
return isLocalUser ? !passwordFormState.isTokenChecked : false;
}),
});

const passwordFormState = reactive({
isPasswordChecked: false,
passwordCheckModalVisible: false,
password: '',
certifiedPassword: '',
Expand All @@ -76,12 +74,8 @@ const passwordFormState = reactive({
});

const passwordCheckFecher = getCancellableFetcher(SpaceConnector.clientV2.identity.token.issue);
const handleChangePassword = debounce(async () => {
if (!passwordFormState.password) {
passwordFormState.isTokenChecked = undefined;
passwordFormState.invalidText = '';
return;
}

const handleConfirmPasswordCheckModal = async () => {
passwordFormState.loading = true;
try {
const result = await passwordCheckFecher<TokenIssueParameters, TokenIssueModel>({
Expand All @@ -97,6 +91,8 @@ const handleChangePassword = debounce(async () => {
passwordFormState.certifiedPassword = passwordFormState.password;
passwordFormState.isTokenChecked = true;
passwordFormState.invalidText = '';
passwordFormState.passwordCheckModalVisible = false;
showSuccessMessage(i18n.t('COMMON.PROFILE.SUCCESS_PASSWORD_CHECK'));
} else {
passwordFormState.isTokenChecked = false;
passwordFormState.invalidText = i18n.t('COMMON.PROFILE.CURRENT_PASSWORD_INVALID');
Expand All @@ -107,18 +103,15 @@ const handleChangePassword = debounce(async () => {
passwordFormState.certifiedPassword = passwordFormState.password;
passwordFormState.isTokenChecked = true;
passwordFormState.invalidText = '';
passwordFormState.passwordCheckModalVisible = false;
showSuccessMessage(i18n.t('COMMON.PROFILE.SUCCESS_PASSWORD_CHECK'));
} else {
passwordFormState.isTokenChecked = false;
passwordFormState.invalidText = i18n.t('COMMON.PROFILE.CURRENT_PASSWORD_INVALID');
}
} finally {
passwordFormState.loading = false;
}
}, 800);

const handleConfirmPasswordCheckModal = () => {
passwordFormState.isPasswordChecked = true;
passwordFormState.passwordCheckModalVisible = false;
};
const handleOpenPasswordCheckModal = () => {
passwordFormState.passwordCheckModalVisible = true;
Expand All @@ -140,7 +133,7 @@ const handleClickCancel = () => {
<p-heading :title="$t('MY_PAGE.ACCOUNT.ACCOUNT_N_PROFILE')" />
</template>
<template #extra>
<p-button v-if="!passwordFormState.isPasswordChecked && storeState.authType === 'LOCAL'"
<p-button v-if="!passwordFormState.isTokenChecked && storeState.authType === 'LOCAL'"
@click="handleOpenPasswordCheckModal"
>
{{ $t('COMMON.PROFILE.EDIT_ACCOUNT_INFO') }}
Expand Down Expand Up @@ -180,7 +173,7 @@ const handleClickCancel = () => {
<p-button-modal :header-title="$t('COMMON.PROFILE.PASSWORD_CHECK_TITLE')"
:visible.sync="passwordFormState.passwordCheckModalVisible"
:loading="passwordFormState.loading"
:disabled="!passwordFormState.isTokenChecked"
:disabled="passwordFormState.password.length < 8"
size="sm"
@confirm="handleConfirmPasswordCheckModal"
@cancel="handleClickCancel"
Expand All @@ -198,10 +191,8 @@ const handleClickCancel = () => {
type="password"
placeholder="Password"
appearance-type="masking"
:readonly="passwordFormState.loading"
:invalid="invalid"
block
@update:value="handleChangePassword"
/>
</template>
</p-field-group>
Expand Down
21 changes: 21 additions & 0 deletions packages/language-pack/console-translation-2.8.babel
Original file line number Diff line number Diff line change
Expand Up @@ -25937,6 +25937,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>SUCCESS_PASSWORD_CHECK</name>
<definition_loaded>false</definition_loaded>
<description/>
<comment/>
<default_text/>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>ja-JP</language>
<approved>false</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>TIMEZONE</name>
<definition_loaded>false</definition_loaded>
Expand Down
1 change: 1 addition & 0 deletions packages/language-pack/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,7 @@
"ROLE": "Role",
"SEND_LINK": "Send user a password reset link",
"SET_MANUALLY": "Set password manually",
"SUCCESS_PASSWORD_CHECK": "Password successfully verified",
"TIMEZONE": "Time Zone",
"TITLE": "Profile"
},
Expand Down
1 change: 1 addition & 0 deletions packages/language-pack/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,7 @@
"ROLE": "権限",
"SEND_LINK": "パスワードリセットメール送信",
"SET_MANUALLY": "管理者がパスワードを設定する",
"SUCCESS_PASSWORD_CHECK": "パスワードが正常に確認されました。",
"TIMEZONE": "タイムゾーン",
"TITLE": "個人情報"
},
Expand Down
1 change: 1 addition & 0 deletions packages/language-pack/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,7 @@
"ROLE": "권한",
"SEND_LINK": "사용자에게 비밀번호 재설정 이메일 발송",
"SET_MANUALLY": "관리자가 대신 비밀번호 설정",
"SUCCESS_PASSWORD_CHECK": "비밀번호가 성공적으로 인증되었습니다.",
"TIMEZONE": "타임존",
"TITLE": "개인 정보"
},
Expand Down
Loading