vdomah / oc-jwtauth

JWTAuth plugin for October CMS wich provides token based authentication
MIT License
27 stars 20 forks source link

Auth guard is not defined. #21

Closed snakemastr closed 4 years ago

snakemastr commented 4 years ago

I have a fresh install octobercms with Octobro/Api and was looking for a good oAuth plugin. Unfortanetly I am getting the error Auth guard is not defined when I'm trying to login. I am creating a login request with Postman POST request and have submitted my fields in the form-data body.

Also, can I create a user for the API only? Right now it is mixing with my customers users but I would like to restrict the API user(s) or group to the API only.

vdomah commented 4 years ago

Hi, 1st question, please provide more details if you can.

2nd question: you can define your own user model in config by setting env variable: https://github.com/vdomah/oc-jwtauth/blob/3b98fc1ecd71bd3fb871382a42e5dbcb5631633e/config/auth.php#L62

snakemastr commented 4 years ago
  1. I was typing my reply as I noticed that the guard name was empty. If OctoberCMS has a config/auth.php, the auth.php in your plugin is ignored. Does this mean my way of installing plugins is wrong or is this desired behaviour? I would think the configs are extending each other, not overriding completely.. I use the backend plugin manager for installation. I have now pasted your config in my auth.php and the plugin works as expected! Awesome :-D

  2. Also good to know. One of the used plugins creates customer model on login if no model is present so I have to catch that in case of my own User.

Thank you so much

snakemastr commented 4 years ago

Ah, config/auth.php was added with the recent upgrade to Laravel V6 (Sep 8).

vdomah commented 4 years ago

About config/auth.php 1 that surprised me, because I fixed that in past plugin releases. Thanks for pointing that it’s Laravel 6 problem, I’ll investigate

beatriznbarroso commented 2 years ago

Hey @vdomah I just had the same issue with your Plugin version 1.0.12 and Laravel 6, is this part of a new release?

sanPuerquitoProgramador commented 1 year ago

If you are using WinterCMS you can add the content of oc-jwtauth/config/auth.php inside wintercms/config/auth.php and, considering you are using the Winter version of Users pluging you need to change too


    'providers' => [
        'users' => [
            'driver' => env('AUTH_PROVIDERS_USERS_DRIVER', 'eloquent'),
            'model' => env('AUTH_PROVIDERS_USERS_MODEL', '\RainLab\User\Models\User'),
        ],

for

    'providers' => [
        'users' => [
            'driver' => env('AUTH_PROVIDERS_USERS_DRIVER', 'eloquent'),
            'model' => env('AUTH_PROVIDERS_USERS_MODEL', '\Winter\User\Models\User'),
        ],