diff --git a/extensions/authentication-jwt/src/__tests__/acceptance/jwt.component.test.ts b/extensions/authentication-jwt/src/__tests__/acceptance/jwt.component.test.ts index 5f8dff1d526d..255d807fde42 100644 --- a/extensions/authentication-jwt/src/__tests__/acceptance/jwt.component.test.ts +++ b/extensions/authentication-jwt/src/__tests__/acceptance/jwt.component.test.ts @@ -11,8 +11,9 @@ import { } from '@loopback/testlab'; import {genSalt, hash} from 'bcryptjs'; import * as _ from 'lodash'; -import {TestApplication} from '../fixtures/application'; +import {UserServiceBindings} from '../..'; import {UserRepository} from '../../repositories'; +import {TestApplication} from '../fixtures/application'; describe('jwt authentication', () => { let app: TestApplication; @@ -54,7 +55,7 @@ describe('jwt authentication', () => { }); await app.boot(); - userRepo = await app.get('repositories.UserRepository'); + userRepo = await app.get(UserServiceBindings.USER_REPOSITORY_NAME); await createUsers(); await app.start(); } diff --git a/extensions/authentication-jwt/src/jwt-authentication-component.ts b/extensions/authentication-jwt/src/jwt-authentication-component.ts index 7e15fbebaec8..1ee3c5fc86a5 100644 --- a/extensions/authentication-jwt/src/jwt-authentication-component.ts +++ b/extensions/authentication-jwt/src/jwt-authentication-component.ts @@ -29,8 +29,10 @@ export class JWTAuthenticationComponent implements Component { // user bindings Binding.bind(UserServiceBindings.USER_SERVICE).toClass(MyUserService), - Binding.bind('repositories.UserRepository').toClass(UserRepository), - Binding.bind('repositories.UserCredentialsRepository').toClass( + Binding.bind(UserServiceBindings.USER_REPOSITORY_NAME).toClass( + UserRepository, + ), + Binding.bind(UserServiceBindings.USER_CREDENTIALS_REPOSITORY_NAME).toClass( UserCredentialsRepository, ), ]; diff --git a/extensions/authentication-jwt/src/keys.ts b/extensions/authentication-jwt/src/keys.ts index e70fd226f96e..96d6793751f5 100644 --- a/extensions/authentication-jwt/src/keys.ts +++ b/extensions/authentication-jwt/src/keys.ts @@ -25,4 +25,7 @@ export namespace UserServiceBindings { 'services.user.service', ); export const DATASOURCE_NAME = 'jwtdb'; + export const USER_REPOSITORY_NAME = 'repositories.UserRepository'; + export const USER_CREDENTIALS_REPOSITORY_NAME = + 'repositories.UserCredentialsRepository'; }