-
Notifications
You must be signed in to change notification settings - Fork 271
Add option to switch authentication guards #141
Add option to switch authentication guards #141
Conversation
Have you seen #87? Exactly similar to our use case here, hasn't been merged yet. |
@soham2008xyz @jorenvanhee - it seems that #87 is similar but not quite the same although I do agree that they are probably addressing the same issue. I think the main point of difference is that 87 includes the guard whereas this one doesn't. |
public function broker() | ||
{ | ||
$passwords = config('backpack.base.passwords') | ||
?: config('auth.defaults.passwords'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NL?
{ | ||
$this->middleware('guest'); | ||
$guard = config('backpack.base.guard') | ||
?: config('auth.defaults.guard'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NL?
return redirect($this->redirectPath()); | ||
} | ||
|
||
protected function guard() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHP Doc?
protected function guard() | ||
{ | ||
$guard = config('backpack.base.guard') | ||
?: config('auth.defaults.guard'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NL?
{ | ||
$this->middleware('guest'); | ||
$guard = config('backpack.base.guard') | ||
?: config('auth.defaults.guard'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NL?
protected function guard() | ||
{ | ||
$guard = config('backpack.base.guard') | ||
?: config('auth.defaults.guard'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NL?
public function handle($request, Closure $next) | ||
{ | ||
$guard = config('backpack.base.guard') | ||
?: config('auth.defaults.guard'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NL?
|
||
class AuthComposer | ||
{ | ||
public function compose(View $view) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHP Doc?
public function compose(View $view) | ||
{ | ||
$guard = config('backpack.base.guard') | ||
?: config('auth.defaults.guard'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NL?
<!-- <li><a href="{{ url('/') }}"><i class="fa fa-home"></i> <span>Home</span></a></li> --> | ||
|
||
@if (Auth::guest()) | ||
@if ($backpackAuth->guest()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did $backpackAuth
come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the AuthComposer.
Is there something more that I can do to get this PR merged? If this one gets merged, I will also have to update the |
@jorenvanhee this looks like a duplicate of #87 which has had some discussion over. |
@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:
Honestly, I think "pretty awesome" is the word for this PR :-) |
@jorenvanhee , @lloy0076 - I've merged this into a separate branch and done @lloy0076 's suggestions: #165 Let's move the conversation there, please. |
Closing this - let's move the conversation there. |
@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
Responses being
|
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
user
guard and anadmin
guard. If theuser
guard is the default one, then it was impossible to use theadmin
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 theuser_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...