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 266f4b5 commit 6cb9686
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 {

This comment has been minimized.

Copy link
@mairatma

mairatma Dec 23, 2015

Could you add some docs to this file? At least one for the class, explaining its purpose, and one for the btoa function, following the convention we're following on other files.

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

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

export default Btoa;

0 comments on commit 6cb9686

Please sign in to comment.