index.obj.js 853 B

12345678910111213141516171819202122
  1. // 云对象教程: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj
  2. // jsdoc语法提示教程:https://ask.dcloud.net.cn/docs/#//ask.dcloud.net.cn/article/129
  3. module.exports = {
  4. _before() {
  5. const clientInfo = this.getClientInfo()
  6. const secretType = clientInfo.secretType
  7. const methodName = this.getMethodName()
  8. const clientInfos = uniCloud.getClientInfos()
  9. // methodName 是客户端调用的方法名
  10. // secretType 是客户端调用 uniCloud.importObject 传递的参数 secretMethods
  11. if (methodName === 'secureTest' && secretType !== 'both') {
  12. const error = new Error('客户端指定的secretType不为both,拒绝此次请求')
  13. error.code = 'INVALID_SECRET_TYPE'
  14. throw error // 拒绝本次请求
  15. }
  16. },
  17. secureTest() {
  18. return {
  19. returnBy: "encryption-object.secureTest"
  20. }
  21. }
  22. }