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

Option to allow only authenticated requests #8

Open
madebyfabian opened this issue Oct 9, 2023 · 2 comments
Open

Option to allow only authenticated requests #8

madebyfabian opened this issue Oct 9, 2023 · 2 comments

Comments

@madebyfabian
Copy link

I am using this plugin to send a contact form email., this will be handled by a server.
My WPGraphQL server does not require authentication for queries, only for mutations. (e.g. an unauthenticated user of the API can query information, but is not able to mutate any data). This is archived by unchecking this WPGraphQL setting:
Bildschirmfoto 2023-10-09 um 13 44 08

I see that this plugin also allows unauthenticated request to make mutations (sending emails).

I would like to have an option in the settings where I can limit the ability to send emails to authenticated requests only.

@madebyfabian
Copy link
Author

The origins option does not work on servers:

{
    "data": {
        "sendEmail": {
            "to": "example@example.com",
            "sent": false,
            "replyTo": "",
            "origin": "",
            "message": "Origin not allowed, set origin in settings",
            "clientMutationId": null
        }
    },
    "extensions": {
        "debug": [
            {
                "type": "DEBUG_LOGS_INACTIVE",
                "message": "GraphQL Debug logging is not active. To see debug logs, GRAPHQL_DEBUG must be enabled."
            }
        ]
    }
}

So this is not an option.

@kevinmac61
Copy link

headers: {
'Content-Type': 'application/json',
Origin: 'http://localhost:5173',
}

that worked for me

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