@edgedev/firebase 2.1.67 → 2.1.68
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/edgeFirebase.ts +10 -2
- package/package.json +1 -1
package/edgeFirebase.ts
CHANGED
|
@@ -125,6 +125,7 @@ interface newUser {
|
|
|
125
125
|
specialPermissions: specialPermission[];
|
|
126
126
|
meta: object;
|
|
127
127
|
isTemplate?: boolean;
|
|
128
|
+
customRegCode?: string;
|
|
128
129
|
subCreate?: {
|
|
129
130
|
rootPath: string, // This must be a collection path (odd number of segments) since a document will be created and assigned to ther user here.
|
|
130
131
|
role: string,
|
|
@@ -1205,8 +1206,10 @@ export const EdgeFirebase = class {
|
|
|
1205
1206
|
private generateUserMeta = async (userMeta: newUser): Promise<actionResponse> => {
|
|
1206
1207
|
const roles: role[] = userMeta.roles || [];
|
|
1207
1208
|
const specialPermissions: specialPermission[] = userMeta.specialPermissions || [];
|
|
1209
|
+
const docId = userMeta?.customRegCode || "";
|
|
1208
1210
|
delete userMeta.roles;
|
|
1209
1211
|
delete userMeta.specialPermissions;
|
|
1212
|
+
delete userMeta.customRegCode;
|
|
1210
1213
|
|
|
1211
1214
|
let isTemplate = false
|
|
1212
1215
|
if (Object.prototype.hasOwnProperty.call(userMeta, "isTemplate") && userMeta.isTemplate) {
|
|
@@ -1235,8 +1238,13 @@ export const EdgeFirebase = class {
|
|
|
1235
1238
|
}
|
|
1236
1239
|
|
|
1237
1240
|
const onlyMeta = { meta: userMeta.meta, userId: "", uid: this.user.uid, roles:{}, specialPermissions:{}, isTemplate, subCreate, templateUserId: "" };
|
|
1238
|
-
|
|
1239
|
-
|
|
1241
|
+
let docRef;
|
|
1242
|
+
if (!docId) {
|
|
1243
|
+
docRef = await addDoc(collection(this.db, "staged-users"), onlyMeta );
|
|
1244
|
+
} else {
|
|
1245
|
+
docRef = doc(this.db, "staged-users", docId);
|
|
1246
|
+
await setDoc(docRef, onlyMeta);
|
|
1247
|
+
}
|
|
1240
1248
|
for (const role of roles) {
|
|
1241
1249
|
await this.storeUserRoles(docRef.id, role.collectionPath, role.role);
|
|
1242
1250
|
}
|