update-user-info.js 553 字节
Newer Older
study夏羽's avatar
study夏羽 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
const {
  userCollection
} = require('../../common/constants')
const {
  USER_STATUS
} = require('../../common/constants')
async function setUserStatus (uid, status) {
  const updateData = {
    status
  }
  if (status !== USER_STATUS.NORMAL) {
    updateData.valid_token_date = Date.now()
  }
  await userCollection.doc(uid).update({
    status
  })
  // TODO 此接口尚不完善,例如注销后其他客户端可能存在有效token,支持Redis后此处会补充额外逻辑
  return {
    errCode: 0
  }
}

module.exports = {
  setUserStatus
}