-
Notifications
You must be signed in to change notification settings - Fork 271
[Feature][0.9][Merged] Custom auth guard #165
Changes from 16 commits
ccbf8fb
a592571
2fd3f86
08b9390
feac647
87839c9
2813799
37b49e1
107c1f3
a5a8015
2e1eea2
83758c6
edb3e52
5cd6190
353d230
5b50727
b153b4e
bb99618
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Backpack\Base\app\Models; | ||
|
||
use App\User; | ||
use Backpack\Base\app\Notifications\ResetPasswordNotification as ResetPasswordNotification; | ||
|
||
class BackpackUser extends User | ||
{ | ||
protected $table = 'users'; | ||
|
||
/** | ||
* Send the password reset notification. | ||
* | ||
* @param string $token | ||
* | ||
* @return void | ||
*/ | ||
public function sendPasswordResetNotification($token) | ||
{ | ||
$this->notify(new ResetPasswordNotification($token)); | ||
} | ||
|
||
/** | ||
* Build the mail representation of the notification. | ||
* | ||
* @return \Illuminate\Notifications\Messages\MailMessage | ||
*/ | ||
public function toMail($notifiable) | ||
{ | ||
return (new MailMessage()) | ||
->line([ | ||
'You are receiving this email because we received a password reset request for your account.', | ||
'Click the button below to reset your password:', | ||
]) | ||
->action('Reset Password', url(config('backpack.base.route_prefix').'/password/reset', $this->token)) | ||
|
||
->line('If you did not request a password reset, no further action is required.'); | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,3 +42,38 @@ function backpack_avatar_url($user) | |
} | ||
} | ||
} | ||
|
||
if (!function_exists('backpack_guard_name')) { | ||
/* | ||
* Returns the name of the guard defined | ||
* by the application config | ||
*/ | ||
function backpack_guard_name() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if these should be camelCase? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm... Good point. I vote no. From what I can see, all Laravel helpers are snake_case. I think we should keep that same rule, for consistency. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sigh Standards only exist so they can be broken 🤦♂️ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No they don't. The also exist to cover all existing standards :-) https://xkcd.com/927/ |
||
{ | ||
return config('backpack.base.guard', config('auth.defaults.guard')); | ||
} | ||
} | ||
|
||
if (!function_exists('backpack_auth')) { | ||
/* | ||
* Returns the user instance if it exists | ||
* of the currently authenticated admin | ||
* based off the defined guard. | ||
*/ | ||
function backpack_auth() | ||
{ | ||
return \Auth::guard(backpack_guard_name()); | ||
} | ||
} | ||
|
||
if (!function_exists('backpack_user')) { | ||
/* | ||
* Returns back a user instance without | ||
* the admin guard, however allows you | ||
* to pass in a custom guard if you like. | ||
*/ | ||
function backpack_user() | ||
{ | ||
return backpack_auth()->user(); | ||
} | ||
} |
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.
i18n
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.
Done!