Commit b78f4acf authored by Qingyu Deng's avatar Qingyu Deng

fix: resolve posible racing condition

parent 1e3147e0
......@@ -10,24 +10,22 @@
</template>
<script>
import { fetchCurrentUser } from './service/user';
import { redirectToLogin } from './utils/util';
import { fetchCurrentUser } from "./service/user";
import { redirectToLogin } from "./utils/util";
export default {
async mounted () {
console.log("master debug 2 !!!!!!")
if (this.$store.state.permissions && this.$store.state.userInfo) return
async created() {
console.log("master debug 2 !!!!!!");
if (this.$store.state.permissions && this.$store.state.userInfo) return;
const { status, user } = await fetchCurrentUser();
if (status === 'success') {
this.$store.commit('updateUserInfo', user);
this.$store.dispatch('updateUserPermission', { email: user.email })
if (status === "success") {
this.$store.commit("updateUserInfo", user);
this.$store.dispatch("updateUserPermission", { email: user.email });
} else {
redirectToLogin();
}
},
};
</script>
<style lang="less" src="./global.less"></style>
......@@ -47,12 +47,7 @@
>
</el-form>
<!-- 列表区 -->
<el-table
class="goods_list"
:data="goodsList"
border
stripe
>
<el-table class="goods_list" :data="goodsList" border stripe>
<el-table-column
label="提现用户"
prop="user_id"
......@@ -120,7 +115,10 @@
@click="handleDetail('audit', scope.row.id)"
>审核</el-button
>
<el-popconfirm title="确定解冻吗?" @confirm="handleFinzingFind(scope.row.id)">
<el-popconfirm
title="确定解冻吗?"
@confirm="handleFinzingFind(scope.row.id)"
>
<template #reference>
<el-button
type="text"
......@@ -129,7 +127,7 @@
>
</template>
</el-popconfirm>
<!-- <el-button
type="text"
v-if="searchProps.withdraw_apply_status == '3'"
......@@ -270,6 +268,7 @@ import {
getAll_role_list,
} from "../../../service/Withdrawal/withdrawal";
import { ElMessage } from "element-plus";
import { fetchCurrentUser } from "../../../service/user";
const TABS = {
pending: "0",
......@@ -304,7 +303,7 @@ export default {
searchProps: {
user_id: "", //用户id
page: 1,
count:0,
count: 0,
page_size: 20, //每页条数
status: TABS.pending, //状态
},
......@@ -328,12 +327,12 @@ export default {
TABS,
};
},
created() {
created() {
this.getApplyList();
},
async mounted() {
const res = await this.getPermissionsAll()
console.log(res)
const res = await this.getPermissionsAll();
console.log(res);
if(!res) {
this.$router.push({name: 'Forbidden'})
......@@ -341,28 +340,31 @@ export default {
}
let withdrawlPermission = res.filter(
({name}) => name === "withdrawal_audit"
)
({ name }) => name === "withdrawal_audit"
);
if(withdrawlPermission.length === 0) {
if (withdrawlPermission.length === 0) {
// push to forbidden
this.$router.push({name: 'Forbidden'})
return
this.$router.push({ name: "Forbidden" });
return;
}
console.log("withdrawlPermission", withdrawlPermission)
withdrawlPermission = withdrawlPermission[0]
console.log("withdrawlPermission", withdrawlPermission);
withdrawlPermission = withdrawlPermission[0];
// judge subpermission
let subpermissions = withdrawlPermission.sub_permissions.filter(
({name}) =>name ==="show"
)
if(subpermissions.length === 0) {
this.$router.push({name: 'Forbidden'})
({ name }) => name === "show"
);
if (subpermissions.length === 0) {
this.$router.push({ name: "Forbidden" });
}
},
methods: {
async getPermissionsAll() {
let { email } = this.$store.state.userInfo;
const res = await getAll_role_list(email);
// 不能够信赖 store 中的 email,无法知道全局中的 fetchCurrentUser 处理完毕
// 是一个重构的点
const { user } = await fetchCurrentUser();
const res = await getAll_role_list(user.email);
this.permissions = res;
return res;
},
......@@ -433,7 +435,7 @@ export default {
//获取黑名单
handleBlackList(action) {
const {id, user_id, wallet_id } = this.dialogData.showData;
const { id, user_id, wallet_id } = this.dialogData.showData;
const params = {
id,
user_id,
......@@ -503,8 +505,8 @@ export default {
showMode: "audit", //判断是审核还是查看
}),
(this.award = ""), //奖励明细
(this.outerVisible = false) //外层弹框
},
(this.outerVisible = false); //外层弹框
},
},
computed: {
isAllowedToAudit() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment