mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-17 23:53:25 +02:00
Add a JWT-based LDAP/AD authenticator.
This commit is contained in:
28
lib/util/requtil.js
Normal file
28
lib/util/requtil.js
Normal file
@@ -0,0 +1,28 @@
|
||||
var util = require('util')
|
||||
|
||||
var Promise = require('bluebird')
|
||||
|
||||
function ValidationError(message, errors) {
|
||||
Error.call(this, message)
|
||||
this.name = 'ValidationError'
|
||||
this.errors = errors
|
||||
Error.captureStackTrace(this, ValidationError)
|
||||
}
|
||||
|
||||
util.inherits(ValidationError, Error)
|
||||
|
||||
module.exports.ValidationError = ValidationError
|
||||
|
||||
module.exports.validate = function(req, rules) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
rules()
|
||||
|
||||
var errors = req.validationErrors()
|
||||
if (!errors) {
|
||||
resolve()
|
||||
}
|
||||
else {
|
||||
reject(new ValidationError('validation error', errors))
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user