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

Configuration for changing the User model #6

Closed
fabriciojs opened this issue Jun 30, 2020 · 12 comments
Closed

Configuration for changing the User model #6

fabriciojs opened this issue Jun 30, 2020 · 12 comments
Labels
enhancement New feature or request released

Comments

@fabriciojs
Copy link

Currently the package assumes App\User is the user entity, breaking when we customize such class or namespace.

Would be great to be able to customize this through configuration.

Currently there is a "hacky" workaround though, in case it helps someone:

image

@JeffBeltran
Copy link
Owner

haha dang it, i almost implemented this but wasn't sure if people would even want to use this package. I'll dig around and get a nice solution implemented.

Thanks for mentioning this

@JeffBeltran JeffBeltran added the enhancement New feature or request label Jun 30, 2020
@JeffBeltran
Copy link
Owner

hey @fabriciojs i'm pushing up a (hopeful) fix, testing it locally seems to do the trick.

Not sure if this applies to your use case, but i have it now use the user model that is also used as the authenticated user via the request get_class($request->user()). So as long as you are trying to use this for the same user model that is being used by laravel via auth.php you should be in business.

Feel free to take a look at the PR for reference #9

JeffBeltran pushed a commit that referenced this issue Jul 12, 2020
# [1.1.0](v1.0.1...v1.1.0) (2020-07-12)

### Features

* add support for non-standard user model ([174aa23](174aa23)), closes [#6](#6)
@JeffBeltran
Copy link
Owner

🎉 This issue has been resolved in version 1.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@meyer59
Copy link

meyer59 commented Mar 2, 2021

Hello
I am using Laravel sanctum on model different that the nova logged user. Is it possible to add a key in the config to specify wich model we want to using ?

@JeffBeltran
Copy link
Owner

I'm not sure i understand your question. But to clarify, if the model your nova resource is using is setup with the HasApiTokens trait simply adding the SanctumTokens::make() to your nova resources fields key will make it show up for that nova resource. if this doesn't work for you could you please expand on what you are trying to do?

@meyer59
Copy link

meyer59 commented Mar 2, 2021

174aa23
You are relying on the nova logged user to manage the token. But in some cases (and mine) we attach the token to another entity

@JeffBeltran
Copy link
Owner

that's an older commit and how it was originally handled, it has since been changed via PR #16 to allow any model that is configured for sanctum. If you follow the steps above, does that not work for you?

@meyer59
Copy link

meyer59 commented Mar 2, 2021

i've got a 401 on the sanctum-token api route. But it may not come from the package itself then. thank you

@JeffBeltran
Copy link
Owner

no problem, i took a quick look to see if there is a reason this should happen but i don't recall adding any gates/policies for this tool... i would be curious why you are getting that though since the api route should be name spaced correctly and not have any collisions

@meyer59
Copy link

meyer59 commented Mar 19, 2021

Quick follow up.. we discovered what was causing this, it was a custom conf by our end that check nova path to logout some other guard. This conf wasn't taking into consideration the nova-vendor path used by the package to create/get the tokens. So the route returned 401.

@JeffBeltran
Copy link
Owner

ah ok cool, so if i understand this the issue was caused by the custom config you created and not associated with a change we made?

@meyer59
Copy link

meyer59 commented Mar 19, 2021

Yes exaclty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

No branches or pull requests

3 participants