Selaa lähdekoodia

feat:限制用户登录权限

coder 2 vuotta sitten
vanhempi
commit
c05e9954b4
1 muutettua tiedostoa jossa 15 lisäystä ja 0 poistoa
  1. 15 0
      public/auto-login.html

+ 15 - 0
public/auto-login.html

@@ -117,6 +117,21 @@
                     dataType: "json",
                     success: (res) => {
                       if (res.code == 1) {
+                        const userInfo = res.data
+                        if ((!Array.isArray(userInfo.user_org.length)) && userInfo.user_org.length == 0) {
+                          alert('账号未绑定机构,您没有权限访问该应用')
+                          return
+                        }
+                        // uo_type 2是学校 1是教育局
+                        const uo_type = userInfo.user_org[userInfo.user_org.length - 1].uo_type
+                        if (uo_type == '1' && tag.startsWith('xd')) {
+                          alert('您是教育局用户,无法访问该应用')
+                          return
+                        }
+                        if (uo_type == '2' && tag.startsWith('jd')) {
+                          alert('您是学校用户,无法访问该应用')
+                          return
+                        }
                         localStorage.setItem('userInfo', JSON.stringify(res.data));
                         location.href = '/app/mobile/' + (tag ? ('#/?tag=' + tag) : '');
                       } else {