Fix for auth logout test case.

This commit is contained in:
mike12345567 2023-02-24 17:42:22 +00:00
parent d6b0b7610a
commit 8fb5168d56
3 changed files with 9 additions and 4 deletions

View File

@ -225,7 +225,12 @@ export async function platformLogout(opts: PlatformLogoutOpts) {
const sessionIds = sessions.map(({ sessionId }) => sessionId)
await invalidateSessions(userId, { sessionIds, reason: "logout" })
const user = await userCache.getUser(userId)
await events.auth.logout(user.email)
let user: User | undefined
try {
user = await userCache.getUser(userId)
} catch {
user = undefined
}
await events.auth.logout(user?.email)
await userCache.invalidateUser(userId)
}

View File

@ -24,7 +24,7 @@ async function login(source: LoginSource, email: string) {
await publishEvent(Event.AUTH_LOGIN, properties)
}
async function logout(email: string) {
async function logout(email?: string) {
const identity = await identification.getCurrentIdentity()
const properties: LogoutEvent = {
userId: identity.id,

View File

@ -15,7 +15,7 @@ export interface LoginEvent extends BaseEvent {
export interface LogoutEvent extends BaseEvent {
userId: string
audited: {
email: string
email?: string
}
}