Add "Send password reset email" button to backend users update page (#723)

This commit is contained in:
Suhas P R 2022-10-13 15:05:23 +05:30 committed by GitHub
parent c6a2fe557c
commit 2fc9997542
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 2 deletions

View File

@ -1,5 +1,6 @@
<?php namespace Backend\Controllers;
use Mail;
use Lang;
use Flash;
use Backend;
@ -233,4 +234,30 @@ class Users extends Controller
]
];
}
/**
* Send password reset mail
*/
public function update_onManualPasswordReset($recordId)
{
$user = $this->formFindModelObject($recordId);
if ($user) {
$code = $user->getResetPasswordCode();
$link = Backend::url('backend/auth/reset/' . $user->id . '/' . $code);
$data = [
'name' => $user->full_name,
'link' => $link,
];
Mail::send('backend::mail.restore', $data, function ($message) use ($user) {
$message->to($user->email, $user->full_name)->subject(trans('backend::lang.account.password_reset'));
});
}
Flash::success(Lang::get('backend::lang.account.manual_password_reset_success'));
return Redirect::refresh();
}
}

View File

@ -0,0 +1,12 @@
<div class="loading-indicator-container">
<button
type="button"
data-request="onManualPasswordReset"
data-load-indicator="<?= e(trans('backend::lang.account.sending')) ?>"
data-request-confirm="<?= e(trans('backend::lang.account.manual_password_reset_confirm')) ?>"
class="btn btn-primary wn-icon-envelope"
style="width: 100%; text-align: center"
>
<?= e(trans('backend::lang.account.password_reset_email')) ?>
</button>
</div>

View File

@ -75,6 +75,10 @@ return [
'cancel' => 'Cancel',
'delete' => 'Delete',
'ok' => 'OK',
'sending' => 'Sending...',
'password_reset_email' => 'Send password reset email',
'manual_password_reset_confirm' => 'Are you sure you want to send a password reset email to this user?',
'manual_password_reset_success' => 'An email has been sent to the user with instructions to reset their password.',
],
'dashboard' => [
'menu_label' => 'Dashboard',

View File

@ -68,11 +68,15 @@ tabs:
secondaryTabs:
fields:
btn_impersonate:
label: ''
label: ""
context: [update]
type: partial
btn_unsuspend:
label: ''
label: ""
context: [update]
type: partial
btn_password_reset:
label: ""
context: [update]
type: partial
avatar: