|
|
@@ -97,7 +97,11 @@ export const CustomWxworkAuthGuard: CanActivateFn = async (route, state) => {
|
|
|
let userInfo;
|
|
|
try {
|
|
|
userInfo = await wxAuth.getUserInfo();
|
|
|
- console.log('✅ 获取用户信息成功:', userInfo?.name);
|
|
|
+ console.log('✅ 获取用户信息成功:', {
|
|
|
+ name: userInfo?.name,
|
|
|
+ userid: userInfo?.userid,
|
|
|
+ cid
|
|
|
+ });
|
|
|
} catch (err) {
|
|
|
console.log('⚠️ 需要授权,跳转到激活页面');
|
|
|
// 需要授权,跳转到激活页面
|
|
|
@@ -113,13 +117,37 @@ export const CustomWxworkAuthGuard: CanActivateFn = async (route, state) => {
|
|
|
|
|
|
// 检查用户是否已激活
|
|
|
const profile = await wxAuth.currentProfile();
|
|
|
-
|
|
|
+ console.log('🔎 currentProfile 查询结果:', {
|
|
|
+ id: profile?.id,
|
|
|
+ isActivated: profile?.get?.('isActivated')
|
|
|
+ });
|
|
|
+
|
|
|
if (!profile || !profile.get('isActivated')) {
|
|
|
+ // 回退:直接按 userid 查询 Profile,避免因未登录或缓存导致的取数失败
|
|
|
+ try {
|
|
|
+ const Parse = FmodeParse.with('nova');
|
|
|
+ const q = new Parse.Query('Profile');
|
|
|
+ q.equalTo('userid', userInfo.userid);
|
|
|
+ const p2 = await q.first();
|
|
|
+ console.log('🔎 回退 Profile 查询结果:', {
|
|
|
+ id: p2?.id,
|
|
|
+ isActivated: p2?.get?.('isActivated')
|
|
|
+ });
|
|
|
+ if (p2 && p2.get('isActivated')) {
|
|
|
+ // 已激活:执行自动登录并放行
|
|
|
+ await wxAuth.autoLogin(userInfo);
|
|
|
+ console.log('✅ 回退校验通过(已激活),允许访问');
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.warn('⚠️ 回退 Profile 查询异常:', e);
|
|
|
+ }
|
|
|
+
|
|
|
console.log('⚠️ 用户未激活,跳转到激活页面');
|
|
|
await router.navigate(['/wxwork', cid, 'activation']);
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 用户已激活,自动登录
|
|
|
await wxAuth.autoLogin(userInfo);
|
|
|
|