22 lines
636 B
TypeScript
22 lines
636 B
TypeScript
|
import {isOAuth2Scope, OAuth2Scope, ScopeRepository} from '../types'
|
||
|
import {Inject, Injectable} from '../../../di'
|
||
|
import {Config} from '../../../service/Config'
|
||
|
import {Awaitable, Maybe} from '../../../util'
|
||
|
|
||
|
@Injectable()
|
||
|
export class ConfigScopeRepository extends ScopeRepository {
|
||
|
@Inject()
|
||
|
protected readonly config!: Config
|
||
|
|
||
|
find(id: string): Awaitable<Maybe<OAuth2Scope>> {
|
||
|
const scope = this.config.get(`oauth2.scopes.${id}`)
|
||
|
if ( isOAuth2Scope(scope) ) {
|
||
|
return scope
|
||
|
}
|
||
|
}
|
||
|
|
||
|
findByName(name: string): Awaitable<Maybe<OAuth2Scope>> {
|
||
|
return this.find(name)
|
||
|
}
|
||
|
}
|