g***@163.com
g***@163.com
  • 发布:2023-12-26 14:15
  • 更新:2023-12-26 14:15
  • 阅读:132

云对象的如何统一处理token呢?

分类:uniCloud

想在_before中统一检测token,然后返回401状态码,但是好像_before中的return不生效,大家是怎么处理的呢?

  _before() {  
    const httpInfo = this.getHttpInfo();  
    const methodName = this.getMethodName();  

    const whiteList = ['login', 'add'];  
    if (!whiteList.includes(methodName) && !httpInfo.headers.token) {  
      return {  
        mpserverlessComposedResponse: true,  
        statusCode: 401,  
      };  
    }  
  },
2023-12-26 14:15 负责人:无 分享
已邀请:

要回复问题请先登录注册