Skip to content

Commit

Permalink
fix: new user not saving in database
Browse files Browse the repository at this point in the history
  • Loading branch information
dead8309 committed Jan 25, 2024
1 parent 0d63807 commit b823e03
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,16 @@ export class FirebaseJWTStrategy extends JWTStrategy {
},
...params,
});
const [entity = null] = result.data ? result.data : result;
if (!result.data || result.data.length === 0) {
return result;
}
const entity = result.data.find((entry: any) => entry.uid === id);
return entity;
}

async createEntity(user: DecodedIdToken, params: Params) {
const data = await this.getEntityData(user, null, params);
return this.entityService.create(data, params);
return await this.entityService.create(data, params);
}

async updateEntity(
Expand All @@ -80,7 +83,7 @@ export class FirebaseJWTStrategy extends JWTStrategy {
) {
const id = existingEntity['_id'];
const data = await this.getEntityData(user, existingEntity, params);
return this.entityService.patch(id, data, params);
return await this.entityService.patch(id, data, params);
}

async getEntityData(
Expand Down

0 comments on commit b823e03

Please sign in to comment.