Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions modules/backend/controllers/Users.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace Backend\Controllers;

use Mail;
use Lang;
use Flash;
use Backend;
Expand Down Expand Up @@ -233,4 +234,30 @@ protected function generatePermissionsField()
]
];
}

/**
* 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();
}
}
12 changes: 12 additions & 0 deletions modules/backend/controllers/users/_btn_password_reset.php
Original file line number Diff line number Diff line change
@@ -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>
4 changes: 4 additions & 0 deletions modules/backend/lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
'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',
Expand Down
8 changes: 6 additions & 2 deletions modules/backend/models/user/fields.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down