mall数据库文件
This commit is contained in:
21
services/analytics/auth.uts
Normal file
21
services/analytics/auth.uts
Normal file
@@ -0,0 +1,21 @@
|
||||
import supa from '@/components/supadb/aksupainstance.uts'
|
||||
|
||||
export function getUserIdOrNull(): string | null {
|
||||
try {
|
||||
const sessionInfo = supa.getSession()
|
||||
if (sessionInfo == null || sessionInfo.user == null) return null
|
||||
const userObj = sessionInfo.user as any
|
||||
if (userObj.getString != null) {
|
||||
return (userObj.getString('id') as string | null)
|
||||
}
|
||||
if (userObj.id != null) {
|
||||
return String(userObj.id)
|
||||
}
|
||||
if (typeof userObj === 'object' && 'id' in userObj) {
|
||||
return String((userObj as any).id)
|
||||
}
|
||||
return null
|
||||
} catch (e) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user