Skip to content

Commit

Permalink
Fixing BasicAuth due to missing btoa().
Browse files Browse the repository at this point in the history
  • Loading branch information
henvic committed Dec 22, 2015
1 parent 2d3e161 commit 0f0d7e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/api/Launchpad.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict';

import core from 'bower:metal/src/core';
import Auth from '../api/Auth';
import Auth from './Auth';
import Btoa from '../btoa/Btoa';
import Embodied from '../api-query/Embodied';
import Filter from '../api-query/Filter';
import Query from '../api-query/Query';
Expand Down Expand Up @@ -403,7 +404,7 @@ class Launchpad {
clientRequest.header('Authorization', 'Bearer ' + this.auth_.token());
} else {
var credentials = this.auth_.username() + ':' + this.auth_.password();
clientRequest.header('Authorization', 'Basic ' + btoa(credentials));
clientRequest.header('Authorization', 'Basic ' + Btoa.btoa(credentials));
}
}

Expand Down
13 changes: 13 additions & 0 deletions src/btoa/Btoa.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

class Btoa {
static btoa(stringToEncode) {
if (typeof btoa === 'function') {
return btoa(stringToEncode);
}

return new Buffer(stringToEncode.toString(), 'binary');
}
}

export default Btoa;

0 comments on commit 0f0d7e6

Please sign in to comment.