Skip to content

Commit

Permalink
Merge 449f069 into b064b6d
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-abramow committed Nov 23, 2018
2 parents b064b6d + 449f069 commit 0a55b12
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions common/models/access-token.js
Expand Up @@ -209,6 +209,11 @@ module.exports = function(AccessToken) {
if (typeof id === 'string') {
// Add support for oAuth 2.0 bearer token
// http://tools.ietf.org/html/rfc6750

// To prevent Error: Model::findById requires the id argument
// with loopback-datasource-juggler 2.56.0+
if (id === '') continue;

if (id.indexOf('Bearer ') === 0) {
id = id.substring(7);
// Decode from base64
Expand Down
10 changes: 10 additions & 0 deletions test/access-token.test.js
Expand Up @@ -200,6 +200,16 @@ describe('loopback.token(options)', function() {
.end(done);
});

it('should generate a 401 on a current user literal route with empty authToken',
function(done) {
var app = createTestApp(null, done);
request(app)
.get('/users/me')
.set('authorization', '')
.expect(401)
.end(done);
});

it('should generate a 401 on a current user literal route with invalid authToken',
function(done) {
var app = createTestApp(this.token, done);
Expand Down

0 comments on commit 0a55b12

Please sign in to comment.