remove-authorized-app.js 650 B

123456789101112131415161718192021222324252627282930
  1. const {
  2. dbCmd,
  3. userCollection
  4. } = require('../../common/constants')
  5. /**
  6. * 移除用户登录授权
  7. * @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#remove-authorized-app
  8. * @param {Object} params
  9. * @param {String} params.uid 用户id
  10. * @param {String} params.appId 取消授权的应用的AppId
  11. * @returns
  12. */
  13. module.exports = async function (params = {}) {
  14. const schema = {
  15. uid: 'string',
  16. appId: 'string'
  17. }
  18. this.middleware.validate(params, schema)
  19. const {
  20. uid,
  21. appId
  22. } = params
  23. await userCollection.doc(uid).update({
  24. dcloud_appid: dbCmd.pull(appId)
  25. })
  26. return {
  27. errCode: 0
  28. }
  29. }