-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add events for
EmailVerification
entity
- Loading branch information
1 parent
cfbb941
commit 59676c0
Showing
5 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/user-management/interfaces/email-verification.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
type EmailVerificationStatus = | ||
| { | ||
status: 'succeeded'; | ||
} | ||
| { | ||
status: 'failed'; | ||
error: { | ||
code: string; | ||
message: string; | ||
}; | ||
}; | ||
|
||
export type EmailVerification = { | ||
object: 'email_verification'; | ||
email: string; | ||
ipAddress: string | null; | ||
userAgent: string | null; | ||
userId: string | null; | ||
} & EmailVerificationStatus; | ||
|
||
export type EmailVerificationResponse = { | ||
object: 'email_verification'; | ||
email: string; | ||
ip_address: string | null; | ||
user_agent: string | null; | ||
user_id: string | null; | ||
} & EmailVerificationStatus; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/user-management/serializers/email-verification.serializer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { EmailVerification, EmailVerificationResponse } from '../interfaces'; | ||
|
||
export const deserializeEmailVerification = ( | ||
emailVerification: EmailVerificationResponse, | ||
): EmailVerification => { | ||
const common = { | ||
object: 'email_verification', | ||
email: emailVerification.email, | ||
ipAddress: emailVerification.ip_address, | ||
userAgent: emailVerification.user_agent, | ||
userId: emailVerification.user_id, | ||
} as const; | ||
|
||
if (emailVerification.status === 'failed') { | ||
return { | ||
...common, | ||
status: emailVerification.status, | ||
error: emailVerification.error, | ||
}; | ||
} | ||
|
||
return { | ||
...common, | ||
status: emailVerification.status, | ||
}; | ||
}; |