You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 23, 2020. It is now read-only.
I basically made it possible to switch authentication guards for backpack. This makes it possible to use a different guard besides the default one (from config/auth.php).
For instance, you have a guard for the users on the public facing part of the website. And you have a different guard for the admins of the website. So a user guard and an admin guard. If the user guard is the default one, then it was impossible to use the admin guard with backpack. This pull request makes it possible to set a specific guard for backpack.
There was already a config option user_model_fqn in backpack, but this only changed the behaviour of the user registration. More info about that in issue #122.
This should be a non-breaking change because the user_model_fqn config option is still present and being used. We could remove it and fetch the used model from the guard configuration, but that would be a breaking change.
This is a breaking change because the views are different now, and they have to be republished. Since it is a breaking change, I will also look into removing the user_model_fqn option.
Actually, the views only need to be republished, if you use the new guard option. The old views just use the default guard. So I'm not sure if this is breaking or not...
jorenvanhee
changed the title
Different user model issue fix
Make it possible to switch authentication guards, fixes #122
May 2, 2017
jorenvanhee
changed the title
Make it possible to switch authentication guards, fixes #122
Add option to switch authentication guards, fixes #122
May 2, 2017
jorenvanhee
changed the title
Add option to switch authentication guards, fixes #122
Add option to switch authentication guard
May 2, 2017
jorenvanhee
changed the title
Add option to switch authentication guard
Add option to switch authentication guards
May 2, 2017
@jorenvanhee - I'm sorry, I've been hacking away at client projects and preparing something super exciting for the Backpack community that will be revealed soon, so I haven't merged PRs for a while. But I'm back now!
@OwenMelbz - is this a complete replacement for #87? Cause if it is, I think I like it a bit better, and it would be a non-breaking change, so it's ready to test and merge. I especially like that:
it avoids using a helper;
the guard usage has better readability
@if ($backpackAuth->guest()) over @if (!backpack_admin()), because it allows you to call ->check() and other methods too;
the configuration file seems easier to understand to me (just replace the Auth middleware if you need to);
it falls back to configuration options from Laravel itself (config/auth.php);
Honestly, I think "pretty awesome" is the word for this PR :-)
Really nice job @jorenvanhee :-)
@tabacitu just this asking if its a replacement for the other PR - answer is no lol, it does not address the issues we face.
Regards to the comments of
it avoids using a helper;
the guard usage has better readability
@if ($backpackAuth->guest()) over @if (!backpack_admin()), because it allows you to call ->check() and other methods too;
the configuration file seems easier to understand to me (just replace the Auth middleware if you need to);
it falls back to configuration options from Laravel itself (config/auth.php);
Responses being
We've just introduced helpers - so that argument I assume is now void?
Not sure this one is entirely true :D even adds another dependency of passing data to the view which means more files will need to be updated for the user
The helper was designed to get the user instance - not query the guard - you can still do that
Again the issue was not that we want a custom guard - the issue is separation of sessions - you cannot be logged into only 1 without customly writing this yourself which adds annoying overheads.
The user can use the default guard if they want
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
None yet
5 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes #122.
I basically made it possible to switch authentication guards for backpack. This makes it possible to use a different guard besides the default one (from
config/auth.php).For instance, you have a guard for the users on the public facing part of the website. And you have a different guard for the admins of the website. So a
userguard and anadminguard. If theuserguard is the default one, then it was impossible to use theadminguard with backpack. This pull request makes it possible to set a specific guard for backpack.There was already a config option
user_model_fqnin backpack, but this only changed the behaviour of the user registration. More info about that in issue #122.This should be a non-breaking change because theuser_model_fqnconfig option is still present and being used. We could remove it and fetch the used model from the guard configuration, but that would be a breaking change.This is a breaking change because the views are different now, and they have to be republished. Since it is a breaking change, I will also look into removing the
user_model_fqnoption.Actually, the views only need to be republished, if you use the new
guardoption. The old views just use the default guard. So I'm not sure if this is breaking or not...