This repository was archived by the owner on Nov 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 271
[Feature][0.9][Merged] Custom auth guard #165
Merged
Merged
Changes from 9 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ccbf8fb
Make it possible to switch guards
jorenvanhee a592571
Use correct guard in views
jorenvanhee 2fd3f86
Fix order of use statements
jorenvanhee 08b9390
Make the admin middleware use the backpack guard
jorenvanhee feac647
Merge branch 'different-user-model-issue-fix' of git://github.com/jor…
tabacitu 87839c9
fixed lloyd's review objections in implementing custom auth guard
tabacitu 2813799
merged master and fixed conflicts:
tabacitu 37b49e1
cleaner config helper usage for guards and passwords
tabacitu 107c1f3
cleaned up admin middleware
tabacitu a5a8015
fixed logout logging out all sessions; applied custom guard to MyAcco…
tabacitu 2e1eea2
added backpack_auth helpers and removed view composers
tabacitu 83758c6
Apply fixes from StyleCI
tabacitu edb3e52
cleanup
tabacitu 5cd6190
comment method
tabacitu 353d230
added BackpackUser model and made it the default user_model_fqn
tabacitu 5b50727
Apply fixes from StyleCI
tabacitu b153b4e
translated reset password email
tabacitu bb99618
Merge branch 'jorenvanhee-different-user-model-issue-fix' of https://…
tabacitu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Backpack\Base\app\Http\ViewComposers; | ||
|
||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\View\View; | ||
|
||
class AuthComposer | ||
{ | ||
public function compose(View $view) | ||
{ | ||
$guard = config('backpack.base.guard') ? config('backpack.base.guard') : config('auth.defaults.guard'); | ||
|
||
$view->with([ | ||
'backpackAuth' => Auth::guard($guard), | ||
]); | ||
} | ||
} |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<div class="user-panel"> | ||
<a class="pull-left image" href="{{ route('backpack.account.info') }}"> | ||
<img src="{{ backpack_avatar_url(Auth::user()) }}" class="img-circle" alt="User Image"> | ||
<img src="{{ backpack_avatar_url($backpackAuth->user()) }}" class="img-circle" alt="User Image"> | ||
</a> | ||
<div class="pull-left info"> | ||
<p><a href="{{ route('backpack.account.info') }}">{{ Auth::user()->name }}</a></p> | ||
<p><a href="{{ route('backpack.account.info') }}">{{ $backpackAuth->user()->name }}</a></p> | ||
<small><small><a href="{{ route('backpack.account.info') }}"><span><i class="fa fa-user-circle-o"></i> {{ trans('backpack::base.my_account') }}</span></a> <a href="{{ backpack_url('logout') }}"><i class="fa fa-sign-out"></i> <span>{{ trans('backpack::base.logout') }}</span></a></small></small> | ||
</div> | ||
</div> |
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
@jorenvanhee - I'm wondering if this is broad enough. Wouldn't this make the $backpackAuth guard available only in views that are loaded within the backpack namespace?
If so, I see the following problem:
I may be mistaken, though. It's been known to happen :-)
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.
Makes sense. What do you think about a helper function
backpackAuth()
?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.
Hmm... I think a more Laravely way to go would be a Facade. Something like
AdminAuth
orBackpackAuth
?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.
A more Laravely way would be to have both a Façade and a helper and then to have arguments on slack/gitter about which is best :(
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.
I'm ok with having both a facade and a helper function. Just like the
auth
helper in Laravel. The documentation says: "The auth function returns an authenticator instance. You may use it instead of the Auth facade for convenience:". I'll update the code if you're ok with that :)Uh oh!
There was an error while loading. Please reload this page.
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.
Having both is probably the better way, given that Laravel does that too. We might be able to avoid the arguments on slack/gitter bit though with a bit of luck (or just agreeing with me 👿).
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.
Agreed!