Authentication Meanjs身份验证问题

Authentication Meanjs身份验证问题,authentication,caching,meanjs,Authentication,Caching,Meanjs,伙计们,我有时在访问我的meanjs应用程序时遇到问题。它有时有效,但有时我只是得到“未授权使用此资源”。了解我的身份验证有时失败的原因 'use strict'; /** * Module dependencies */ var acl = require('acl'); // Using the memory backend acl = new acl(new acl.memoryBackend()); /** * Invoke Admin Permissions */

伙计们,我有时在访问我的meanjs应用程序时遇到问题。它有时有效,但有时我只是得到“未授权使用此资源”。了解我的身份验证有时失败的原因

   'use strict';

/**
 * Module dependencies
 */
var acl = require('acl');

// Using the memory backend
acl = new acl(new acl.memoryBackend());

/**
 * Invoke Admin Permissions
 */
exports.invokeRolesPolicies = function () {
  acl.allow([{
    roles: ['admin'],
    allows: [{
      resources: '/api/users',
      permissions: '*'
    }, {
      resources: '/api/users/:userId',
      permissions: '*'
    }]
  }, {
    roles: ['user'],
    allows: [{
      resources: '/api/users',
      permissions: ['get', 'post']
    }, {
      resources: '/api/users/:userId',
      permissions: ['get']
    }]
  }]);
};
/**
 * Check If Admin Policy Allows
 */
exports.isAllowed = function (req, res, next) {
  var roles = (req.user) ? req.user.roles : ['guest'];

  // Check for user roles
  acl.areAnyRolesAllowed(roles, req.route.path, req.method.toLowerCase(), function (err, isAllowed) {
    if (err) {
      // An authorization error occurred
      return res.status(500).send('Unexpected authorization error');
    } else {
      if (isAllowed) {
        // Access granted! Invoke next middleware
        return next();
      } else {
        return res.status(403).json({
          message: 'User is not authorized'
        });
      }
    }
  });
};

这是我用于访问应用程序的策略。

检查您使用的用户是否具有正确的权限,例如,
角色
数组中的
“user”
“admin”值。@user3632710,我目前在我的浏览器上做了一个艰苦的休息,这修复了这个问题,所以我认为这是一个缓存问题,过期的令牌在某个点上没有刷新