fix: fallback qdreader uid to ywguid
This commit is contained in:
+14
-5
@@ -31,17 +31,23 @@ function b64decode(s) {
|
||||
while (raw.length % 4) raw += '='
|
||||
try { return decodeURIComponent(escape(atob(raw))) } catch (e) { return '' }
|
||||
}
|
||||
function isRealUid(uid) {
|
||||
uid = String(uid === undefined || uid === null ? '' : uid).trim()
|
||||
return /^\d{5,}$/.test(uid) ? uid : ''
|
||||
}
|
||||
function uidFromQDHeader(qdheader) {
|
||||
const decoded = b64decode(qdheader)
|
||||
return decoded ? String(decoded.split('|')[0] || '').trim() : ''
|
||||
if (!decoded) return ''
|
||||
const parts = decoded.split('|').map(x => String(x || '').trim())
|
||||
return isRealUid(parts[0])
|
||||
}
|
||||
function parseJson(s, def) { try { return JSON.parse(s) } catch (e) { return def } }
|
||||
function findUid(obj) {
|
||||
if (!obj || typeof obj !== 'object') return ''
|
||||
const keys = ['UserId', 'userId', 'UserID', 'userid', 'uid', 'UID']
|
||||
for (const key of keys) {
|
||||
const val = obj[key]
|
||||
if (val !== undefined && val !== null && String(val).trim()) return String(val).trim()
|
||||
const uid = isRealUid(obj[key])
|
||||
if (uid) return uid
|
||||
}
|
||||
for (const key in obj) {
|
||||
const val = obj[key]
|
||||
@@ -56,9 +62,12 @@ function getUid(cookie, body) {
|
||||
const jar = parseCookie(cookie)
|
||||
let uid = uidFromQDHeader(jar.QDHeader || jar.qdheader || jar.QDHEADER || '')
|
||||
if (uid) return uid
|
||||
if (jar.uid) return String(jar.uid)
|
||||
uid = isRealUid(jar.uid || jar.userid || jar.userId || jar.UserId)
|
||||
if (uid) return uid
|
||||
const obj = parseJson(body || '', null)
|
||||
return findUid(obj)
|
||||
uid = findUid(obj)
|
||||
if (uid) return uid
|
||||
return isRealUid(jar.ywguid || jar.gwguid || jar.guid)
|
||||
}
|
||||
function notify(title, sub, msg) {
|
||||
$notify(title, sub || '', msg || '')
|
||||
|
||||
Reference in New Issue
Block a user