Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- system.use("info.webtoolkit.Base64");
- var username = "admin";
- var password = "password";
- var auth = "Basic " + Base64.encode(username + ":"+ password);
- checkAuth = function() {
- if (!this.request.headers.hasOwnProperty('Authorization') || (this.request.headers.hasOwnProperty('Authorization') && (auth != this.request.headers['Authorization']))) {
- this.response.headers['WWW-Authenticate'] = 'Basic realm="SmartAPI"';
- this.response.code = 401;
- this.response.body = "Not Authorized\n";
- throw this.response;
- }
- }
Add Comment
Please, Sign In to add comment