@@ -151,29 +151,33 @@ const {
151151 decodedToken,
152152 username,
153153 roles,
154+ resourceRoles,
154155 keycloak,
155156
156157 // Functions
157158 hasRoles,
159+ hasResourceRoles,
158160} = useKeycloak ()
159161```
160162
161- | State | Type | Description |
162- | --------------- | --------------------------- | ------------------------------------------------------ |
163- | isAuthenticated | ` Ref<boolean> ` | If ` true ` the user is authenticated. |
164- | isPending | ` Ref<boolean> ` | If ` true ` the authentication request is still pending. |
165- | hasFailed | ` Ref<boolean> ` | If ` true ` authentication request has failed. |
166- | token | ` Ref<string> ` | ` token ` is the raw value of the JWT token. |
167- | decodedToken | ` Ref<T> ` | ` decodedToken ` is the decoded value of the JWT token. |
168- | username | ` Ref<string> ` | ` username ` the name of our user. |
169- | roles | ` Ref<string[]> ` | ` roles ` is a list of the users roles. |
170- | keycloak | ` Keycloak.KeycloakInstance ` | ` keycloak ` is the instance of the keycloak-js adapter. |
163+ | State | Type | Description |
164+ | --------------- | ------------------------------ | ------------------------------------------------------------------- |
165+ | isAuthenticated | ` Ref<boolean> ` | If ` true ` the user is authenticated. |
166+ | isPending | ` Ref<boolean> ` | If ` true ` the authentication request is still pending. |
167+ | hasFailed | ` Ref<boolean> ` | If ` true ` authentication request has failed. |
168+ | token | ` Ref<string> ` | ` token ` is the raw value of the JWT token. |
169+ | decodedToken | ` Ref<T> ` | ` decodedToken ` is the decoded value of the JWT token. |
170+ | username | ` Ref<string> ` | ` username ` the name of our user. |
171+ | roles | ` Ref<string[]> ` | ` roles ` is a list of the users roles. |
172+ | resourceRoles | ` Ref<Record<string, string[]> ` | ` resourceRoles ` is a list of the users roles in specific resources. |
173+ | keycloak | ` Keycloak.KeycloakInstance ` | ` keycloak ` is the instance of the keycloak-js adapter. |
171174
172175#### Functions
173176
174- | Function | Type | Description |
175- | -------- | ------------------------------ | ------------------------------------------------------------ |
176- | hasRoles | ` (roles: string[]) => boolean ` | ` hasRoles ` returns true if the user has all the given roles. |
177+ | Function | Type | Description |
178+ | ---------------- | ------------------------------------------------ | ---------------------------------------------------------------------------------- |
179+ | hasRoles | ` (roles: string[]) => boolean ` | ` hasRoles ` returns true if the user has all the given roles. |
180+ | hasResourceRoles | ` (roles: string[], resource: string) => boolean ` | ` hasResourceRoles ` returns true if the user has all the given roles in a resource. |
177181
178182# License
179183
0 commit comments