Skip to content
This repository was archived by the owner on Oct 4, 2019. It is now read-only.
This repository was archived by the owner on Oct 4, 2019. It is now read-only.

Add possibility for custom role handling #12

@StuckiSimon

Description

@StuckiSimon

While most use cases can be resolved using the <Authorize /> component there are some special ones which might require a custom handling.

Example:

  • Redirect to route based on rights
if (hasRole('admin')) {
  redirect('/admin')
} else if (hasRole('accountant') {
  redirect('/booking')
}

It is possible to implement these use cases with the existing component, but it seems odd to use <Authorize neededRoles=[] /> in such a case.

My proposal is a HOC (Higher Order Component):

Usage:

withRoles(Component)

This HOC could then also be used by the <Authorize /> component itself.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions