Skip to content

Commit

Permalink
fix: clean db user with cej_id at first login process
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementNumericite committed Dec 19, 2024
1 parent 6460173 commit abd600b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
6 changes: 2 additions & 4 deletions webapp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
## [0.75.1](https://github.com/SocialGouv/carte-jeune-engage/compare/v0.75.0...v0.75.1) (2024-12-17)


### Bug Fixes

* log ([50f4c2e](https://github.com/SocialGouv/carte-jeune-engage/commit/50f4c2e65b2b008d3ceb4196e22d305dccb0fa7a))
- log ([50f4c2e](https://github.com/SocialGouv/carte-jeune-engage/commit/50f4c2e65b2b008d3ceb4196e22d305dccb0fa7a))

# [0.75.0](https://github.com/SocialGouv/carte-jeune-engage/compare/v0.74.1...v0.75.0) (2024-12-17)


### Features

* trpc error log ([ab54ef3](https://github.com/SocialGouv/carte-jeune-engage/commit/ab54ef34604cb8e2c9a6034f471ca1b1bea696d8))
- trpc error log ([ab54ef3](https://github.com/SocialGouv/carte-jeune-engage/commit/ab54ef34604cb8e2c9a6034f471ca1b1bea696d8))

## [0.74.1](https://github.com/SocialGouv/carte-jeune-engage/compare/v0.74.0...v0.74.1) (2024-12-17)

Expand Down
15 changes: 7 additions & 8 deletions webapp/src/server/api/routers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,6 @@ const generateAndSendOTP = async (
});
} else if (!!octopushResponse.otp_request_token) {
if (firstLogin) {
console.log("tying to create : ", {
email: email,
otp_request_token: octopushResponse.otp_request_token,
password: generateRandomPassword(16),
phone_number: phone_number,
userEmail: user_email,
cej_id: cej_id,
});
await payload.create({
collection: "users",
data: {
Expand Down Expand Up @@ -414,6 +406,13 @@ export const userRouter = createTRPCRouter({
if (!users.docs.length) {
// For CEJ users, we generate an OTP only if the CEJ ID is valid
if (cej_id) {
await ctx.payload.delete({
collection: "users",
where: {
cej_id: { equals: cej_id },
},
});

await generateAndSendOTP(ctx.payload, userInput, true);
return { kind: "otp" };
}
Expand Down

0 comments on commit abd600b

Please sign in to comment.