-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bouncer functions are missing types for server #41
Labels
bug
Something isn't working
Comments
I temporarily fixed it with patch-package module by appending nuxt-authorization+0.3.2.patchdiff --git a/node_modules/nuxt-authorization/dist/runtime/server/utils/bouncer.d.ts b/node_modules/nuxt-authorization/dist/runtime/server/utils/bouncer.d.ts
index ab46b57..585a9b2 100644
--- a/node_modules/nuxt-authorization/dist/runtime/server/utils/bouncer.d.ts
+++ b/node_modules/nuxt-authorization/dist/runtime/server/utils/bouncer.d.ts
@@ -3,12 +3,12 @@ import type { BouncerAbility, BouncerArgs } from '../../../utils/index.js';
/**
* Allows a user to perform an action based on their role and the data.
*/
-export declare function allows<Event extends H3Event, Ability extends BouncerAbility<any>>(event: Event, ability: Ability, ...args: BouncerArgs<Ability>): Promise<boolean>;
+export declare function allowsEvent<Event extends H3Event, Ability extends BouncerAbility<any>>(event: Event, ability: Ability, ...args: BouncerArgs<Ability>): Promise<boolean>;
/**
* Denies a user to perform an action based on their role and the data.
*/
-export declare function denies<Event extends H3Event, Ability extends BouncerAbility<any>>(event: Event, ability: Ability, ...args: BouncerArgs<Ability>): Promise<boolean>;
+export declare function deniesEvent<Event extends H3Event, Ability extends BouncerAbility<any>>(event: Event, ability: Ability, ...args: BouncerArgs<Ability>): Promise<boolean>;
/**
* Throws an error if the user is not allowed to perform an action.
*/
-export declare function authorize<Event extends H3Event, Ability extends BouncerAbility<any>>(event: Event, ability: Ability, ...args: BouncerArgs<Ability>): Promise<void>;
+export declare function authorizeEvent<Event extends H3Event, Ability extends BouncerAbility<any>>(event: Event, ability: Ability, ...args: BouncerArgs<Ability>): Promise<void>;
diff --git a/node_modules/nuxt-authorization/dist/runtime/server/utils/bouncer.js b/node_modules/nuxt-authorization/dist/runtime/server/utils/bouncer.js
index 680999c..d4fbb8d 100644
--- a/node_modules/nuxt-authorization/dist/runtime/server/utils/bouncer.js
+++ b/node_modules/nuxt-authorization/dist/runtime/server/utils/bouncer.js
@@ -1,14 +1,14 @@
import { allows as _allows, denies as _denies, authorize as _authorize, AuthorizationError } from "../../../utils";
import { createError } from "#imports";
-export async function allows(event, ability, ...args) {
+export async function allowsEvent(event, ability, ...args) {
const user = await event.context.$authorization.resolveServerUser();
return _allows(ability, user, ...args);
}
-export async function denies(event, ability, ...args) {
+export async function deniesEvent(event, ability, ...args) {
const user = await event.context.$authorization.resolveServerUser();
return _denies(ability, user, ...args);
}
-export async function authorize(event, ability, ...args) {
+export async function authorizeEvent(event, ability, ...args) {
try {
const user = await event.context.$authorization.resolveServerUser();
await _authorize(ability, user, ...args); |
Hey 👋, I'm sorry about it but I'm unable to understand why it does not work. 🙁 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello!
I found this module which I really like for my needs, but I ran into an issue with types of the bouncer functions on the server side. For example the
authorize
method. The method is auto-imported, but the code imported is for the client part of the application and I can't force it to the correct type whereevent
is the first argument. I also tried to import it manually from the module itself but also with no luck.The file on the screenshot is nested in the
server/
directory.Sample recreation on StackBlitz,
https://stackblitz.com/edit/github-bgkk3g6m?file=server%2Fapi%2Fhello.ts
Could you please help me on that?
Thank you
The text was updated successfully, but these errors were encountered: