add verification support

This commit is contained in:
AceDataCloud committed 2022-04-05 19:38:04 +08:00
1 parent 91a5420a76
commit cc43fb39e8
10 files changed
+98 -29

No files matched your search

+47 -15
View File
@@ -3,25 +3,57 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { ElMessageBox } from 'element-plus';
import AuthService from '@/services/auth/service';
import { ITokenResponse } from '@/services/auth/types';
export default defineComponent({
name: 'VerificationAlert',
mounted() {
ElMessageBox.alert(this.$t('auth.message.needVerification'), this.$t('common.message.info'), {
confirmButtonText: this.$t('common.button.verify'),
// cancelButtonText: this.$t('common.button.cancel'),
type: 'warning',
center: true,
showClose: false,
'show-cancel-button': false,
'close-on-click-modal': false,
'close-on-press-escape': false,
'close-on-hash-change': false
})
.then(() => {
window.open('https://auth.test.zhishuyun.com/user/verify');
computed: {
verified() {
return this.$store.getters.user.isVerified;
},
refresh() {
return this.$route.query.refresh;
}
},
methods: {
checkAndShowVerificationAlert() {
if (this.verified) {
return;
}
ElMessageBox.alert(this.$t('auth.message.needVerification'), this.$t('common.message.info'), {
confirmButtonText: this.$t('common.button.verify'),
// cancelButtonText: this.$t('common.button.cancel'),
type: 'warning',
center: true,
showClose: false,
showCancelButton: false,
closeOnClickModal: false,
closeOnPressEscape: false,
closeOnHashChange: false
})
.catch(() => {});
.then(() => {
window.open('https://auth.test.zhishuyun.com/user/verify?redirect=' + window.location.href + '?refresh=1');
})
.catch(() => {});
}
},
async mounted() {
if (this.refresh) {
AuthService.refreshToken({
refresh: this.$store.getters.refreshToken
}).then(async ({ data: data }: { data: ITokenResponse }) => {
await this.$store.dispatch('setAccessToken', data.access);
await this.$store.dispatch('getMe');
this.$router.push({
...this.$route,
query: {}
});
this.checkAndShowVerificationAlert();
});
} else {
this.checkAndShowVerificationAlert();
}
}
});
</script>