bixi
Version:
企业级中后台前端解决方案
34 lines (26 loc) • 1.09 kB
Markdown
order: 100
title: TokenService
type: Documents
`ITokenService` contains some service class for Token operations, such as get current Token information:
```ts
constructor(@Inject(BIXI_SERVICE_TOKEN) private tokenService: ITokenService) {
console.log(tokenService.get().token);
// When JWT
console.log(tokenService.get<JWTTokenModel>(JWTTokenModel).token);
}
```
## API
### Property
| Name | Type | Description |
|---------------|----------------|----------------------------------------------------------|
| `[login_url]` | `string` | Get the login address of `BixiAuthConfig` configuration |
| `[referrer]` | `AuthReferrer` | Get routing before authorization failure |
### Method
| Name | Return Type | Description |
| ----- | --- | --- |
| `change()` | `Observable<ITokenModel>` | Token changed callback |
| `set(data: ITokenModel)` | `boolean` | Set Token |
| `get(type?: any)` | `ITokenModel` | Get Token |
| `clear(options?: { onlyToken: boolean })` | `void` | Clear Token |