Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Policies
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- module.exports = function(req, res, next) {
- // User is allowed, proceed to the next policy,
- // or if this is the last policy, the controller
- if (req.header("Authorization")) {
- var auth = req.header("Authorization");
- var tmp = auth.split(' '); // Split on a space, the original auth looks like "Basic Y2hhcmxlczoxMjM0NQ==" and we need the 2nd part
- var buf = new Buffer(tmp[1], 'base64'); // create a buffer and tell it the data coming in is base64
- var plain_auth = buf.toString(); // read it back out as a string
- var creds = plain_auth.split(':'); // split on a ':'
- var username = creds[0];
- var password = creds[1];
- var url = req.host;
- return Oauth2ClientCredentialService.validateClientCredentials(username, password, url)
- .then(function(result){
- next(result);
- }).catch(function(err){
- next("You are not permitted to perform this action.haahahahahahahh");
- });
- }
- // User is not allowed
- // (default res.forbidden() behavior can be overridden in `config/403.js`)
- return res.forbidden('You are not permitted to perform this action.');
- };
- //RESPONSE HEADER
- 500 Internal Server Error
- //RESPONSE BODY:
- {
- "url": "127.0.0.1",
- "clientid": "blahblah",
- "clientpassword": "blahblah",
- "email": "BLAH811@gmail.com",
- "createdAt": "2017-04-24T05:10:46.996Z",
- "updatedAt": "2017-04-24T05:10:46.996Z",
- "id": "58fd88d6e345fd2b1da4bda1"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement