Fix undefineds

This commit is contained in:
Adria Navarro 2023-01-13 14:48:01 +00:00
parent ff10fa422b
commit 748b55c732
2 changed files with 5 additions and 4 deletions

View File

@ -28,9 +28,10 @@ export async function syncUser(ctx: Ctx) {
}
}
let previousApps = isUser(previousUser)
? Object.keys(previousUser.roles).map(appId => appId)
: []
let previousApps =
previousUser && isUser(previousUser)
? Object.keys(previousUser.roles).map(appId => appId)
: []
const roles = deleting ? {} : user.roles
// remove props which aren't useful to metadata

View File

@ -70,6 +70,6 @@ export interface AdminUser extends User {
}
}
export function isUser(user: any): user is User {
export function isUser(user: object): user is User {
return !!(user as User).roles
}