1 | import { AuthenticationStrategy, AuthenticationBase } from './core'
|
2 | import { Application, Service } from '@feathersjs/feathers'
|
3 |
|
4 | export class AuthenticationBaseStrategy implements AuthenticationStrategy {
|
5 | authentication?: AuthenticationBase
|
6 | app?: Application
|
7 | name?: string
|
8 |
|
9 | setAuthentication(auth: AuthenticationBase) {
|
10 | this.authentication = auth
|
11 | }
|
12 |
|
13 | setApplication(app: Application) {
|
14 | this.app = app
|
15 | }
|
16 |
|
17 | setName(name: string) {
|
18 | this.name = name
|
19 | }
|
20 |
|
21 | get configuration(): any {
|
22 | return this.authentication.configuration[this.name]
|
23 | }
|
24 |
|
25 | get entityService(): Service {
|
26 | const { service } = this.configuration
|
27 |
|
28 | if (!service) {
|
29 | return null
|
30 | }
|
31 |
|
32 | return this.app.service(service) || null
|
33 | }
|
34 | }
|