designmynight / laravel-mongodb-passport

A package to get Laravel Passport working with MongoDB
MIT License
67 stars 75 forks source link

Database [users] not configured. After revoke or token expired #14

Closed kertul closed 5 years ago

kertul commented 5 years ago

Hi. I really helped you make this package, but right now I have a problem when I revoke the token, or when the token has expired. I get the error message "Database [users] not configured."

please help me, my client is waiting and I'm stuck here. This is my code

'mongodb' => [ 'driver' => 'mongodb', 'host' => env('DB_HOST', 'localhost'), 'port' => env('DB_PORT', 27017), 'database' => env('DB_DATABASE'), 'username' => env('DB_USERNAME'), 'password' => env('DB_PASSWORD'), 'options' => [ 'database' => 'users' ] ],

`public function logout(Request $request) { $request->user()->token()->revoke();

    return response()->json([
        'message' => 'Logout successfully'
    ], 200);
}`
StevePorter92 commented 5 years ago

Hey @kertul, this sounds like it could be a mongo problem

Perhaps something to do with your db configuration for auth?

'options' => [ 'database' => 'users' ] ]

What version of mongo are you using, what version of the driver are you using, and can you provide the complete stack trace?

kertul commented 5 years ago

I use this.

"laravel/framework": "5.6.*", "laravel/passport": "^7.0", "designmynight/laravel-mongodb-passport": "^1.1", "jenssegers/mongodb": "^3.4", MongoDB version 4.0.2

StevePorter92 commented 5 years ago

At a guess it sounds like theres a problem with the database you are selecting.

Whats the value of your default connection? 'default' => env('DB_CONNECTION', 'sqlite'),. Is this pointing to your mongo configuration. Are you overriding the connection/database on some of your models?

kertul commented 5 years ago

Finally, I did some testing and I found a problem with the validation form that I made. I forgot to set the connection to the "exists rule"

But now I need an explanation, why does this problem not occur when the users table is empty? Can anyone explain it to me.

StevePorter92 commented 5 years ago

Glad you’ve fixed your issue :smile:. Sounds like this isn't a bug in this library. Closing this issue.