feat: add force password reset feature

This commit is contained in:
2022-09-04 20:30:49 +01:00
parent 8a3b4c432a
commit 997b57f419
5 changed files with 138 additions and 1 deletions

View File

@@ -34,6 +34,7 @@ use App\Http\Requests\SearchPlayerRequest;
use App\Http\Requests\UpdateUserRequest;
use App\Notifications\ChangedPassword;
use App\Notifications\EmailChanged;
use App\Notifications\PasswordAdminResetNotification;
use App\Services\AccountSuspensionService;
use App\Traits\DisablesFeatures;
use App\Traits\HandlesAccountDeletion;
@@ -275,6 +276,33 @@ class UserController extends Controller
}
/**
* Removes the user's password and notifies them.
*
* @param User $user The user to remove the password for
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/
public function forcePasswordReset(User $user) {
$this->authorize('adminEdit', $user);
$user->notify(new PasswordAdminResetNotification());
$user->password = null;
$user->save();
Log::alert("Removed account password", [
'target' => $user,
'actor' => Auth::user()
]);
return redirect()
->back()
->with('success', 'Account password removed.');
}
/**
* Delete the given user's account
*