Skip to content

Commit

Permalink
feat/privy: changes to support new flow when email changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Thangaraj-Ideas2it authored and madan-ideas2it committed Jun 7, 2024
1 parent b9a40e6 commit 1ac454e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion apps/web-api/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class AuthService implements OnModuleInit {
async deleteUserAccount(externalAuthToken: string, externalAuthId: string) {
const clientToken = await this.getAuthClientToken();
await axios.delete(
`${process.env.AUTH_API_URL}/admin/accounts/external/${externalAuthId}`,
`${process.env.AUTH_API_URL}/accounts/external/${externalAuthId}`,
{
headers: {
Authorization: `Bearer ${clientToken}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,12 +706,17 @@ export class ParticipantsRequestService {
});

// Other member Changes

await tx.member.update({
where: { uid: dataFromDB.referenceUid },
data: { ...dataToSave },
data: {
...dataToSave,
...(isEmailChange && isExternalIdAvailable && { externalId: null }),
},
});

this.logger.info(`Member update request - attibutes updated, requestId -> ${uidToEdit}`)
/* if (isEmailChange && isExternalIdAvailable) {
if (isEmailChange && isExternalIdAvailable) {
// try {
this.logger.info(`Member update request - Initiating email change - newEmail - ${dataToSave.email}, oldEmail - ${existingData.email}, externalId - ${existingData.externalId}, requestId -> ${uidToEdit}`)
const response = await axios.post(
Expand All @@ -732,15 +737,9 @@ export class ParticipantsRequestService {
const headers = {
Authorization: `Bearer ${clientToken}`,
};
const authPayload = {
email: dataToSave.email,
existingEmail: existingData.email.toLowerCase().trim(),
userId: existingData.externalId,
deleteAndReplace: true,
};
await axios.patch(
`${process.env.AUTH_API_URL}/admin/accounts/email`,
authPayload,

await axios.delete(
`${process.env.AUTH_API_URL}/admin/accounts/external/${existingData.externalId}`,
{ headers: headers }
);
// } catch (e) {
Expand All @@ -750,7 +749,7 @@ export class ParticipantsRequestService {
// }
// }
this.logger.info(`Member update request - Email changed, requestId -> ${uidToEdit}`)
} */
}
// Updating status
await tx.participantsRequest.update({
where: { uid: uidToEdit },
Expand Down

0 comments on commit 1ac454e

Please sign in to comment.