Guest User

Untitled

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