Skip to content
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

Object has no member 'requireGuestOnly' #3896

Closed
einarpersson opened this issue Dec 7, 2023 · 2 comments
Closed

Object has no member 'requireGuestOnly' #3896

einarpersson opened this issue Dec 7, 2023 · 2 comments

Comments

@einarpersson
Copy link

According to the docs there exists a

// requires the request client to be unauthenticated, aka. guest
$apis.requireGuestOnly()

but using this throws
TypeError: Object has no member 'requireGuestOnly'

and I can't find it here either

@ganigeorgiev
Copy link
Member

Hm, it seems that I've forgotten to add the binding. I'll update it with the next release.

If you want to emulate the same behavior as the middleware, you can try checking for the authRecord and admin context keys:

if (c.get("admin") || c.get("authRecord")) {
    throw new BadRequestError("The request can be accessed only by guests.")
}

@ganigeorgiev
Copy link
Member

I've added the binding in the develop branch. It will be available with the next v0.20.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants