Guest User

Untitled

a guest
May 17th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. before(function(){
  2. system.use("info.webtoolkit.Base64");
  3. var username = 'foo';
  4. var password = 'bar';
  5. var auth = "Basic " + Base64.encode(username + ":"+ password);
  6. if (!this.request.headers.hasOwnProperty('Authorization') || (this.request.headers.hasOwnProperty('Authorization') && (auth != this.request.headers['Authorization']))) {
  7. this.response.headers['WWW-Authenticate'] = 'Basic realm="Protected Area"';
  8. this.response.code = 401;
  9. this.response.body = "Not Authorized\n";
  10. throw this.response;
  11. }
  12. });
Add Comment
Please, Sign In to add comment