lex-xin преди 3 години
родител
ревизия
afb9951f01
променени са 4 файла, в които са добавени 19 реда и са изтрити 3 реда
  1. 19 3
      src/utils/auth.js
  2. 0 0
      web/index.html
  3. 0 0
      web/static/web/js/app.579a31b9.js
  4. 0 0
      web/static/web/js/app.b316ea24.js

+ 19 - 3
src/utils/auth.js

@@ -2,14 +2,30 @@ import Cookies from 'js-cookie'
 
 const TokenKey = 'Admin-Token'
 
+function getCookieDomain() {
+  let host = location.hostname
+  const ip = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
+  if (ip.test(host) === true || host === 'localhost') return host
+  const regex = /([^]*).*/
+  const match = host.match(regex)
+  if (typeof match !== 'undefined' && match !== null) host = match[1]
+  if (typeof host !== 'undefined' && host !== null) {
+    const strAry = host.split('.')
+    if (strAry.length > 1) {
+      host = strAry[strAry.length - 2] + '.' + strAry[strAry.length - 1]
+    }
+  }
+  return '.' + host
+}
+
 export function getToken() {
-  return Cookies.get(TokenKey)
+  return Cookies.get(TokenKey, { domain: getCookieDomain() })
 }
 
 export function setToken(token) {
-  return Cookies.set(TokenKey, token)
+  return Cookies.set(TokenKey, token, { domain: getCookieDomain() })
 }
 
 export function removeToken() {
-  return Cookies.remove(TokenKey)
+  return Cookies.remove(TokenKey, { domain: getCookieDomain() })
 }

Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
web/index.html


Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
web/static/web/js/app.579a31b9.js


Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
web/static/web/js/app.b316ea24.js


Някои файлове не бяха показани, защото твърде много файлове са промени