How to use the NotAuthorizedError function from restify

Find comprehensive JavaScript restify.NotAuthorizedError code examples handpicked from public code repositorys.

46
47
48
49
50
51
52
53
54
55
        return next();
    } else {
        res.status(401);
        res.setHeader('Connection', 'close');
        res.end();
        return next(new Restify.NotAuthorizedError());
    }
} else {
    return next();
}
fork icon9
star icon12
watch icon48

+ 3 other calls in file

34
35
36
37
38
39
40
41
42
43
        var i = methods.length;
        while(i--) {
            if(methods[i] == req.method)
                return next();
        }
        return next(new restify.NotAuthorizedError("Methods not defined for this user and this schema"));
    });
});

server.post('/user', UserREST.createUser);
fork icon0
star icon2
watch icon13

35
36
37
38
39
40
41
42
43
44
  review: require('../models/review'),
  badgeInstance: require('../models/badge-instance'),
  milestone: require('../models/milestone'),
}

const http403 = restify.NotAuthorizedError
const http404 = restify.ResourceNotFoundError
const http500 = restify.InternalError

function createFinder(modelName, gOpts) {
fork icon46
star icon0
watch icon2

90
91
92
93
94
95
96
97
98
99
    params: req.params,
    limits: req.limits
}, 'capi_limits: dataset limits');

if (req.limit < 0) {
    return next(new restify.NotAuthorizedError(
                util.format('%s: %s', CODE, MESSAGE)));
}

if (req.limit === 0) {
fork icon24
star icon0
watch icon5

+ 3 other calls in file

22
23
24
25
26
27
28
29
30
31
32
33
34


const GCODE_EXTENSIONS = [".nc", ".g", ".gc", ".gcode"];
const OPENSBP_EXTENSIONS = [".sbp", ".sbc"];


var MethodNotAllowedError = errors.MethodNotAllowedError;
var NotAuthorizedError = errors.NotAuthorizedError;
var ResourceNotFoundError = errors.ResourceNotFoundError;


function listify(x) {
    if (x instanceof Array) {
fork icon22
star icon52
watch icon0

4
5
6
7
8
9
10
11
12
var bcrypt = require('bcrypt-nodejs');


module.exports.handler = function(req, res, next) {
    if (!req.params.auth)
        return next(new restify.NotAuthorizedError('Auth token required.'));

    if (!req.params.user_id)
        return next(new restify.InvalidArgumentError('User ID required.'));
fork icon1
star icon1
watch icon5

+ 5 other calls in file

158
159
160
161
162
163
164
165
166
167
  request.log.info({req: request}, 'REQUEST');

  if (process.env.ENV === 'prod'
    && (!request.headers['x-forwarded-proto'] || request.headers['x-forwarded-proto'] !== 'https')) {
    if (request.method !== 'POST' || !validUnsecuredPathRegex.test(request.url)) {
      return next(new restify.NotAuthorizedError('Access through http is not allowed'));
    }
  }
  return next();
});
fork icon36
star icon0
watch icon0

+ 5 other calls in file

110
111
112
113
114
115
116
117
118
119

self.server.use(function validateIpAddresses(req, res, next) {
    // Should we periodically refresh the CNAPI IP address we have?
    if (req.method === 'POST' && [self.cnapiAddr, self.bindip].indexOf(
            req.connection.remoteAddress) === -1) {
        next(new restify.NotAuthorizedError(
            'requests must originate from CNAPI address'));
        return;
    }
    next();
fork icon17
star icon0
watch icon1

28
29
30
31
32
33
34
35
36
37
    }
    return error;
}

function NotAuthorizedError(){
    var error = new restify.NotAuthorizedError();
    error.body.outMsg = sysMsg.SYS_AUTH_TOKEN_ERROR;

    return error;
}
fork icon0
star icon0
watch icon0

+ 3 other calls in file