adminforth 1.1.101 → 1.1.103

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.
@@ -46,7 +46,7 @@ export default class AdminForthBaseConnector implements IAdminForthDataSourceCon
46
46
 
47
47
  createRecord({ resource, record }: { resource: AdminForthResource; record: any; }): Promise<void> {
48
48
  // transform value using setFieldValue and call createRecordOriginalValues
49
- const newRecord = {};
49
+ const newRecord = {...record};
50
50
  for (const col of resource.dataSourceColumns) {
51
51
  newRecord[col.name] = this.setFieldValue(col, record[col.name]);
52
52
  }
@@ -39,7 +39,7 @@ export default class AdminForthBaseConnector {
39
39
  }
40
40
  createRecord({ resource, record }) {
41
41
  // transform value using setFieldValue and call createRecordOriginalValues
42
- const newRecord = {};
42
+ const newRecord = Object.assign({}, record);
43
43
  for (const col of resource.dataSourceColumns) {
44
44
  newRecord[col.name] = this.setFieldValue(col, record[col.name]);
45
45
  }
package/dist/index.js CHANGED
@@ -101,7 +101,7 @@ class AdminForth {
101
101
  catch (e) {
102
102
  this.config.customization.customComponentsDir = undefined;
103
103
  }
104
- if (this.config.auth) {
104
+ if (!this.config.auth) {
105
105
  if (!this.config.auth.resourceId) {
106
106
  throw new Error('No config.auth.resourceId defined');
107
107
  }
@@ -118,6 +118,9 @@ class AdminForth {
118
118
  if (!userResource) {
119
119
  throw new Error(`Resource with id "${this.config.auth.resourceId}" not found`);
120
120
  }
121
+ if (!this.config.auth.beforeLoginConfirmation) {
122
+ this.config.auth.beforeLoginConfirmation = [];
123
+ }
121
124
  }
122
125
  if (!this.config.customization) {
123
126
  this.config.customization = {};
@@ -614,12 +617,12 @@ class AdminForth {
614
617
  adminUser = {
615
618
  isRoot: false, dbUser: userRecord,
616
619
  pk: userRecord[userResource.columns.find((col) => col.primaryKey).name],
617
- username
620
+ username,
618
621
  };
619
622
  const beforeLoginConfirmation = this.config.auth.beforeLoginConfirmation;
620
623
  if (beforeLoginConfirmation === null || beforeLoginConfirmation === void 0 ? void 0 : beforeLoginConfirmation.length) {
621
624
  for (const hook of beforeLoginConfirmation) {
622
- const resp = yield hook({ userRecord: adminUser });
625
+ const resp = yield hook({ adminUser });
623
626
  if ((_d = resp === null || resp === void 0 ? void 0 : resp.body) === null || _d === void 0 ? void 0 : _d.setCookie) {
624
627
  (_e = resp === null || resp === void 0 ? void 0 : resp.body) === null || _e === void 0 ? void 0 : _e.setCookie.forEach((cookie) => {
625
628
  this.auth.setCustomCookie({ response, payload: cookie });
package/index.ts CHANGED
@@ -138,7 +138,7 @@ class AdminForth implements IAdminForth {
138
138
  this.config.customization.customComponentsDir = undefined;
139
139
  }
140
140
 
141
- if (this.config.auth) {
141
+ if (!this.config.auth) {
142
142
  if (!this.config.auth.resourceId) {
143
143
  throw new Error('No config.auth.resourceId defined');
144
144
  }
@@ -155,6 +155,10 @@ class AdminForth implements IAdminForth {
155
155
  if (!userResource) {
156
156
  throw new Error(`Resource with id "${this.config.auth.resourceId}" not found`);
157
157
  }
158
+
159
+ if (!this.config.auth.beforeLoginConfirmation) {
160
+ this.config.auth.beforeLoginConfirmation = [];
161
+ }
158
162
  }
159
163
 
160
164
  if (!this.config.customization) {
@@ -708,12 +712,12 @@ class AdminForth implements IAdminForth {
708
712
  adminUser = {
709
713
  isRoot: false, dbUser: userRecord,
710
714
  pk: userRecord[userResource.columns.find((col) => col.primaryKey).name],
711
- username
715
+ username,
712
716
  };
713
717
  const beforeLoginConfirmation = this.config.auth.beforeLoginConfirmation as (BeforeLoginConfirmationFunction[] | undefined);
714
718
  if (beforeLoginConfirmation?.length){
715
719
  for (const hook of beforeLoginConfirmation) {
716
- const resp = await hook({ userRecord:adminUser});
720
+ const resp = await hook({ adminUser });
717
721
  if (resp?.body?.setCookie){
718
722
  resp?.body?.setCookie.forEach((cookie) => {
719
723
  this.auth.setCustomCookie({response,payload:cookie})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "1.1.101",
3
+ "version": "1.1.103",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -615,7 +615,7 @@ export type AfterSaveFunction = (params: {resource: AdminForthResource, adminUse
615
615
  /**
616
616
  * Allow to get user data before login confirmation, will triger when user try to login.
617
617
  */
618
- export type BeforeLoginConfirmationFunction = (params?: { userRecord: AdminUser }) => Promise<{ok:boolean, error?:string, body:{setCookie?:[], redirectTo?: 'string', allowedLogin?: boolean }}>;
618
+ export type BeforeLoginConfirmationFunction = (params?: { adminUser: AdminUser }) => Promise<{ok:boolean, error?:string, body:{setCookie?:[], redirectTo?: 'string', allowedLogin?: boolean }}>;
619
619
 
620
620
  /**
621
621
  * Resource describes one table or collection in database.