edenspiekermann / craft-jwt-auth

Enable authentication to Craft through the use of Javascript Web Tokens (JWT)
MIT License
5 stars 16 forks source link

Disable JWT authentication on console requests #14

Open jackatomix opened 4 years ago

jackatomix commented 4 years ago

Description

Previously the plugin would initialize itself on application load. This is fine, but Craft::$app may be either a craft\web\Application or a craft\console\Application, which are different applications with different use cases.

As seen in https://github.com/edenspiekermann/craft-jwt-auth/issues/11, this would cause all console requests to crash as the console application resolves a console request, and there is no craft\console\Request::headers.

This PR changes the class that the plugin initialzes on from Craft->$app to craft\web\Application, causing the plugin to not attempt to authenticate a user based on the current headers on console requests.

Definition of Done

BenMenking commented 3 years ago

I'm running into this issue too. Manually changing the code using this PR fixes the issue for me. This issue occurred after upgrading to CraftCMS 3.6.3