Skip to content

Commit c76617c

Browse files
feat(component): add new binding for User model (#108)
added new binding for User model gh-107
1 parent 83bb000 commit c76617c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/keys.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import {BindingKey} from '@loopback/context';
1+
import {BindingKey, Constructor} from '@loopback/context';
22
import {MetadataAccessor} from '@loopback/metadata';
33
import {Strategy} from 'passport';
44

55
import {
66
AuthenticateFn,
77
AuthenticationConfig,
88
AuthenticationMetadata,
9+
EntityWithIdentifier,
910
IAuthClient,
1011
IAuthUser,
1112
} from './types';
@@ -51,6 +52,10 @@ export namespace AuthenticationBindings {
5152
export const CONFIG = BindingKey.create<AuthenticationConfig>(
5253
'sf.userAuthentication.config',
5354
);
55+
56+
export const USER_MODEL = BindingKey.create<
57+
Constructor<EntityWithIdentifier>
58+
>('sf.userAuthentication.userModel');
5459
}
5560

5661
export const USER_AUTHENTICATION_METADATA_KEY = MetadataAccessor.create<

src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ export interface IAuthUser {
2020
password?: string;
2121
}
2222

23+
export interface EntityWithIdentifier {
24+
getIdentifier?(): string | undefined;
25+
}
26+
2327
export interface AuthenticationMetadata<T = void> {
2428
strategy: string;
2529
options?: Object;

0 commit comments

Comments
 (0)