diff --git a/packages/auth/docs/getting-started.en-US.md b/packages/auth/docs/getting-started.en-US.md index e7abe0b840..d142fdc67a 100644 --- a/packages/auth/docs/getting-started.en-US.md +++ b/packages/auth/docs/getting-started.en-US.md @@ -49,7 +49,8 @@ Configure the `provideAuth` environment in `app.config.ts`: ```typescript providers: [ // Indicates using JWT style and using `localStorage` to store Token - provideAuth(withJWT(), withLocalStorage()), + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authJWTInterceptor, defaultInterceptor])), + provideAuth(withLocalStorage()), ] ``` diff --git a/packages/auth/docs/getting-started.zh-CN.md b/packages/auth/docs/getting-started.zh-CN.md index 112fd24edf..012e141b17 100644 --- a/packages/auth/docs/getting-started.zh-CN.md +++ b/packages/auth/docs/getting-started.zh-CN.md @@ -49,7 +49,8 @@ npm i -S @delon/auth ```typescript providers: [ // 表示使用JWT风格并用 `localStorage` 存储 Token - provideAuth(withJWT(), withLocalStorage()), + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authJWTInterceptor, defaultInterceptor])), + provideAuth(withLocalStorage()), ] ``` diff --git a/packages/auth/docs/send.en-US.md b/packages/auth/docs/send.en-US.md index 49f7c49ec2..5161ce0054 100644 --- a/packages/auth/docs/send.en-US.md +++ b/packages/auth/docs/send.en-US.md @@ -10,7 +10,7 @@ type: Documents It is better to add the corresponding authentication information to each request through the HTTP interceptor. `@delonn/auth` implements two separate HTTP interceptors based on two different authentication styles. -### withSimple +### authSimpleInterceptor The parameter name and its sending location can be specified via `DelonAuthConfig`, for example: @@ -22,15 +22,15 @@ token_send_place = 'header'; Indicates the `{ token: 'Bearer token_string' }` data in the `header` of each request. -### withJWT +### authJWTInterceptor It is a standard JWT sending rule that automatically adds `{ Authorization: 'Bearer token_string' }` to `header`. ### How to choose? -`withSimple` is a very liberal style, you can put `token` in the request body, request header, etc. +`authSimpleInterceptor` is a very liberal style, you can put `token` in the request body, request header, etc. -`withJWT` is a JWT standard, which needs to ensure that the backend also uses such standards. +`authJWTInterceptor` is a JWT standard, which needs to ensure that the backend also uses such standards. ## How to load @@ -38,9 +38,9 @@ In `app.config.ts` file: ```ts providers: [ - provideAuth(withSimple()), + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authSimpleInterceptor, defaultInterceptor])), // Or JWT - provideAuth(withJWT()), + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authJWTInterceptor, defaultInterceptor])), ] ``` diff --git a/packages/auth/docs/send.zh-CN.md b/packages/auth/docs/send.zh-CN.md index 46b857dfc9..d32634341d 100644 --- a/packages/auth/docs/send.zh-CN.md +++ b/packages/auth/docs/send.zh-CN.md @@ -8,7 +8,7 @@ type: Documents 通过HTTP拦截器在每一个请求中加入相应的认证信息,这是再好不过。`@delonn/auth` 根据两种不同认证风格,实现两种各自的HTTP拦截器。 -### withSimple +### authSimpleInterceptor 透过 `DelonAuthConfig` 可以指定参数名以及其发送位置,例如: @@ -20,15 +20,15 @@ token_send_place = 'header'; 表示在每一个请求的 `header` 加上 `{ token: 'Bearer token_string' }` 数据。 -### withJWT +### authJWTInterceptor 它是一个标准JWT的发送规则,即在 `header` 自动加上 `{ Authorization: 'Bearer token_string' }`。 ### 如何选择? -`withSimple` 是一种自由度非常高的风格,你可以将 `token` 放在请求体、请求头等当中。 +`authSimpleInterceptor` 是一种自由度非常高的风格,你可以将 `token` 放在请求体、请求头等当中。 -`withJWT` 是一个 JWT 标准,这需要确保后端也采用这类标准。 +`authJWTInterceptor` 是一个 JWT 标准,这需要确保后端也采用这类标准。 ## 如何加载 @@ -36,9 +36,10 @@ token_send_place = 'header'; ```ts providers: [ - provideAuth(withSimple()), + // 表示使用JWT风格并用 `localStorage` 存储 Token + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authSimpleInterceptor, defaultInterceptor])), // Or JWT - provideAuth(withJWT()), + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authJWTInterceptor, defaultInterceptor])), ] ``` diff --git a/packages/auth/docs/set.en-US.md b/packages/auth/docs/set.en-US.md index 6fcc342a09..8eb5f4373c 100644 --- a/packages/auth/docs/set.en-US.md +++ b/packages/auth/docs/set.en-US.md @@ -32,7 +32,8 @@ The default is to use `withLocalStorage` persistent storage. You can change othe ```ts providers: [ - provideAuth(withJWT(), withLocalStorage()), + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authJWTInterceptor, defaultInterceptor])), + provideAuth(withLocalStorage()), ] ``` diff --git a/packages/auth/docs/set.zh-CN.md b/packages/auth/docs/set.zh-CN.md index 47306d95d8..3326f2c86f 100644 --- a/packages/auth/docs/set.zh-CN.md +++ b/packages/auth/docs/set.zh-CN.md @@ -30,7 +30,8 @@ constructor(@Inject(DA_SERVICE_TOKEN) service: ITokenService) { ```ts providers: [ - provideAuth(withJWT(), withLocalStorage()), + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authJWTInterceptor, defaultInterceptor])), + provideAuth(withLocalStorage()), ] ``` diff --git a/packages/auth/src/store/cookie-storage.service.ts b/packages/auth/src/store/cookie-storage.service.ts index 79b3d70f81..ac53747452 100644 --- a/packages/auth/src/store/cookie-storage.service.ts +++ b/packages/auth/src/store/cookie-storage.service.ts @@ -9,7 +9,8 @@ import { IStore } from './interface'; * `cookie` storage * * ```ts - * provideAuth(withJWT(), withCookie()) + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authJWTInterceptor, defaultInterceptor])), + provideAuth(withCookie()), * ``` */ export class CookieStorageStore implements IStore { diff --git a/packages/auth/src/store/local-storage.service.ts b/packages/auth/src/store/local-storage.service.ts index 271fb6bfe3..96fe3c1155 100644 --- a/packages/auth/src/store/local-storage.service.ts +++ b/packages/auth/src/store/local-storage.service.ts @@ -9,7 +9,8 @@ export function DA_STORE_TOKEN_LOCAL_FACTORY(): IStore { * `localStorage` storage, **not lost after closing the browser**. * * ```ts - * provideAuth(withJWT(), withLocalStorage()) + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authJWTInterceptor, defaultInterceptor])), + provideAuth(withLocalStorage()), * ``` */ export class LocalStorageStore implements IStore { diff --git a/packages/auth/src/store/session-storage.service.ts b/packages/auth/src/store/session-storage.service.ts index 8922173d79..78bf9ecd54 100644 --- a/packages/auth/src/store/session-storage.service.ts +++ b/packages/auth/src/store/session-storage.service.ts @@ -5,7 +5,8 @@ import { IStore } from './interface'; * `sessionStorage` storage, **lost after closing the browser**. * * ```ts - * provideAuth(withJWT(), withSessionStorage()) + provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authJWTInterceptor, defaultInterceptor])), + provideAuth(withSessionStorage()), * ``` */ export class SessionStorageStore implements IStore {