INNER CODE UNIT · TypeScript
hasRole
tenseijs/tensei · packages/auth/src/index.ts:498
const hasRole = roles.find(r =>
[r.config.name, r.config.slug].includes(roleNameOrSlug)
)
if (hasRole) {
return
}
// persist role for user
const { manager } = this.ctx
manager.assign(this, {
roles: [...roles.map(role => role.config.slug), role.config.slug]
})
await manager.persistAndFlush(this)
}
)