login-authorization-v2 1.1.5 → 2.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,55 +1,30 @@
1
- # login-authorization
2
-
3
- > 登录验证
4
- ## 安装依赖
5
-
6
- ``` bash
7
- # install dependencies
8
- npm install login-authorization --save
9
- # or with yarn
10
- yarn add login-authorization
11
- ```
12
- ## 方法使用说明
13
- ### 初始化:init(requestUrl, loginUrl, systemName) 此方法必须在入口文件中调用
14
- ```bash
15
- import { init } from 'login-authorization';
16
-
17
- init('http://127.0.0.1','http://127.0.0.1/#/login?systemName=Finance', 'Finance').then(res => {
18
- if (res) {
19
- // true 已登录
20
- } else {
21
- // false 未登录
22
- }
23
- })
24
-
25
- 注意:systemName必须和Cognito中配置的系统组名保持一致。
26
-
27
- ```
28
- <font color=#ff0000 size=24>注意:凡是涉及到统一登录系统的loginUrl后面必须将你的系统名称带上,且参数名称为systemName,如果未涉及则不用。</font>
29
- ### 登录成功时需要设置idToken和refreshToken初始值
30
- setIdToken(value)
31
- setRefreshToken(value)
32
- ### 获取idToken:getIdToken()
33
- ```bash
34
- import { getIdToken } from 'login-authorization';
35
-
36
- let idToken = getIdToken(); // 'xxxxxx',如果未登录则为null
37
- ```
38
- ### 获取用户信息:getUserInfo()
39
- ```bash
40
- import { getUserInfo } from 'login-authorization';
41
-
42
- let userInfo = getUserInfo(); //{email: 'xxx', name: 'xxx',...},如果未登录则为null
43
- ```
44
- ### 登出:logout()
45
- ```bash
46
- import { logout } from 'login-authorization';
47
-
48
- logout().then(res => {
49
- if (res) {
50
- // true 登出成功,会自动跳转到登录页面
51
- } else {
52
- // false 登出失败
53
- }
54
- })
55
- ```
1
+ # login-authorization-v2
2
+
3
+ ## 安装
4
+ ```bash
5
+ #npm
6
+ npm install login-authorization-v2
7
+
8
+ #yarn
9
+ yarn add login-authorization-v2
10
+ ```
11
+
12
+ ## 使用文档
13
+ ### 基本使用
14
+ ```javascript
15
+ import { make } from 'login-authorization-v2'
16
+
17
+ const { init } = make({
18
+ brand: 1,
19
+ tenantId: 1,
20
+ moduleName: 'Portal', // 当前模块名称
21
+ moduleBaseUrl: 'https://servers-api.gztest.net:8107', // 后端的 module_base 服务地址
22
+ loginPageUrl: 'http://huangcheng.ddmarketinghub.com:8080', // 如果未登录,跳转的登录页地址
23
+ })
24
+
25
+ init().then(menus => {
26
+ // menus 即为当前用户的菜单权限数据
27
+ }).catch(err => {
28
+ // 任何不能正常登陆的情况都会进入这里
29
+ })
30
+ ```
@@ -0,0 +1,23 @@
1
+ export * from './src/cookie';
2
+ export * from './src/compatible';
3
+ export * from './src/utils';
4
+ import { type ModuleName, type Tenant, type Brand } from './src/types';
5
+ type MakeFnParams = {
6
+ brand: Brand;
7
+ tenantId: Tenant;
8
+ moduleName: ModuleName;
9
+ moduleBaseUrl: string;
10
+ loginPageUrl: string;
11
+ };
12
+ export declare const make: (config: MakeFnParams) => {
13
+ init: () => Promise<{
14
+ groupName: ModuleName;
15
+ icon: string;
16
+ id: number;
17
+ label: string;
18
+ staffEndpoint: boolean;
19
+ url: string;
20
+ }[]>;
21
+ logout: () => Promise<import("axios").AxiosResponse<any, any>>;
22
+ };
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAO3B,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,MAAM,EAAE,KAAK,KAAK,EAAiB,MAAM,aAAa,CAAA;AAIrF,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,KAAK,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,UAAU,CAAA;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,IAAI,GAAI,QAAQ,YAAY;;;;;;;;;;CAqIxC,CAAA"}