fix(security): 安全闸门与 NODE_ENV 解耦,支付/提现 fail-closed
- 新增 SECURE_MODE(仅 ALLOW_INSECURE_DEV_AUTH=1 时放开):后台登录口令、上传、内容检测、核销码归属全部改为默认收紧,修复线上以 NODE_ENV=development 运行时闸门失效 - 提现审核:未开通真实转账且未显式 ALLOW_SANDBOX_PAY=1 时一律 503,杜绝只改状态不打款 - 预支付:未开启沙箱时不再下发沙箱参数;小程序删除预支付失败伪造沙箱成功的兜底,改为抛错 - 订阅消息支持 MINIPROGRAM_STATE=formal|trial|developer 显式配置,避免真实用户收不到通知 - 动态列表/点赞身份统一 normalizeUserId;文档补充安全闸门与订阅消息环境变量 - 109 套件/720 用例全绿,tsc 构建通过
这个提交包含在:
@@ -427,8 +427,10 @@ const syncCurrentUserProfile = async () => {
|
||||
...currentUserProfile.value,
|
||||
...cached
|
||||
};
|
||||
const storedUid = Number(uni.getStorageSync('userId'));
|
||||
if (!storedUid) return currentUserProfile.value;
|
||||
try {
|
||||
const remote = await getUserProfile(cached.id || 1001);
|
||||
const remote = await getUserProfile(storedUid);
|
||||
if (remote && remote.nickname) {
|
||||
const merged = {
|
||||
...cached,
|
||||
|
||||
@@ -368,7 +368,8 @@ import { preloadSubscribeTemplates, requestSubscribeAll } from '@/common/subscri
|
||||
|
||||
const DEFAULT_GUEST_AVATAR = 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=200';
|
||||
const initialUserId = typeof uni !== 'undefined' ? (uni.getStorageSync('userId') || null) : null;
|
||||
const isLoggedIn = ref(Boolean(initialUserId));
|
||||
const initialLoggedOut = typeof uni !== 'undefined' ? (uni.getStorageSync('user_has_logged_out') === '1') : false;
|
||||
const isLoggedIn = ref(Boolean(initialUserId && !initialLoggedOut));
|
||||
const showLoginModal = ref(false);
|
||||
|
||||
// 我的收藏与我的举报反馈
|
||||
@@ -377,7 +378,12 @@ const loadingFavorites = ref(false);
|
||||
const myReportsList = ref([]);
|
||||
|
||||
const loadMyReports = async () => {
|
||||
const uid = user.value.id || uni.getStorageSync('userId') || 1001;
|
||||
if (!isLoggedIn.value) {
|
||||
myReportsList.value = [];
|
||||
return;
|
||||
}
|
||||
const uid = user.value.id || uni.getStorageSync('userId');
|
||||
if (!uid) return;
|
||||
try {
|
||||
const list = await getMyReports(uid);
|
||||
if (Array.isArray(list)) {
|
||||
@@ -409,7 +415,11 @@ const openCoupons = () => {
|
||||
};
|
||||
|
||||
const loadCouponUsable = async () => {
|
||||
const uid = uni.getStorageSync('userId') || 0;
|
||||
if (!isLoggedIn.value) {
|
||||
couponUsable.value = 0;
|
||||
return;
|
||||
}
|
||||
const uid = user.value.id || uni.getStorageSync('userId') || 0;
|
||||
if (!uid) return;
|
||||
try {
|
||||
const res = await getMyCoupons(uid, 'UNUSED');
|
||||
@@ -663,7 +673,9 @@ onMounted(() => {
|
||||
uni.$on('login-success', onLoginSuccess);
|
||||
loadUserProfile();
|
||||
loadPlatformConfigs();
|
||||
loadMyReports();
|
||||
if (isLoggedIn.value) {
|
||||
loadMyReports();
|
||||
}
|
||||
// 预加载订阅消息模板ID,确保点击授权时无需等待网络(保留点击手势)
|
||||
preloadSubscribeTemplates();
|
||||
});
|
||||
@@ -678,11 +690,16 @@ onShow(() => {
|
||||
loadPlatformConfigs();
|
||||
privacyHidePhone.value = uni.getStorageSync('privacy_hide_phone') === '1';
|
||||
noticeSubscribe.value = uni.getStorageSync('notice_subscribe') === '1';
|
||||
loadNoticeUnread();
|
||||
loadCouponUsable();
|
||||
if (isLoggedIn.value) {
|
||||
loadNoticeUnread();
|
||||
loadCouponUsable();
|
||||
loadFavorites();
|
||||
loadMyReports();
|
||||
} else {
|
||||
noticeUnread.value = 0;
|
||||
couponUsable.value = 0;
|
||||
favoriteList.value = [];
|
||||
myReportsList.value = [];
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1030,9 +1047,15 @@ const openFavoritesModal = () => {
|
||||
};
|
||||
|
||||
const loadFavorites = async () => {
|
||||
if (!isLoggedIn.value) {
|
||||
favoriteList.value = [];
|
||||
return;
|
||||
}
|
||||
const uid = user.value.id || uni.getStorageSync('userId');
|
||||
if (!uid) return;
|
||||
loadingFavorites.value = true;
|
||||
try {
|
||||
const list = await getFavorites(user.value.id || 1001);
|
||||
const list = await getFavorites(uid);
|
||||
favoriteList.value = Array.isArray(list) ? list : [];
|
||||
} catch (_) {
|
||||
favoriteList.value = [];
|
||||
@@ -1261,7 +1284,11 @@ const openNotifications = () => {
|
||||
};
|
||||
|
||||
const loadNoticeUnread = async () => {
|
||||
const uid = uni.getStorageSync('userId') || 0;
|
||||
if (!isLoggedIn.value) {
|
||||
noticeUnread.value = 0;
|
||||
return;
|
||||
}
|
||||
const uid = user.value.id || uni.getStorageSync('userId') || 0;
|
||||
if (!uid) return;
|
||||
try {
|
||||
const res = await getNotifications(uid, 1);
|
||||
|
||||
在新工单中引用
屏蔽一个用户