mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-11 03:24:16 +00:00
improve publicData
method
This commit is contained in:
parent
3b7b6fe4fe
commit
f4f4726231
@ -31,14 +31,22 @@ export default class User {
|
|||||||
return User.bridge.get.user(undefined, { _id: user_id })
|
return User.bridge.get.user(undefined, { _id: user_id })
|
||||||
}
|
}
|
||||||
|
|
||||||
static async publicData() {
|
static async publicData(payload = {}) {
|
||||||
const token = await Session.decodedToken()
|
if (!User.bridge) {
|
||||||
|
throw new Error("Bridge is not available")
|
||||||
if (!token) {
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return User.bridge.get.userPublicData({ username: token.username })
|
if (!payload.username && !payload.user_id) {
|
||||||
|
const token = await Session.decodedToken()
|
||||||
|
|
||||||
|
if (token) {
|
||||||
|
payload.username = token.username
|
||||||
|
} else {
|
||||||
|
throw new Error("username or user_id is required")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return User.bridge.get.userPublicData({ username: payload.username, user_id: payload.user_id })
|
||||||
}
|
}
|
||||||
|
|
||||||
static async roles() {
|
static async roles() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user