mirror of
https://github.com/BillyOutlast/UNIT3D.git
synced 2026-02-04 03:01:20 +01:00
Laravel returns numeric strings when an int is saved to cache, which breaks a lot of the logic here. Fixed by removing cache everywhere except rss and middleware, and in those two spots, caching the whole group and not just the id of the group.
66 lines
1.7 KiB
PHP
66 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* NOTICE OF LICENSE.
|
|
*
|
|
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
|
* The details is bundled with this project in the file LICENSE.txt.
|
|
*
|
|
* @project UNIT3D Community Edition
|
|
*
|
|
* @author HDVinnie <hdinnovations@protonmail.com>
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
|
*/
|
|
|
|
namespace App\Actions\Fortify;
|
|
|
|
use App\Models\Group;
|
|
use App\Models\User;
|
|
use App\Services\Unit3dAnnounce;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Support\Facades\Validator;
|
|
use Illuminate\Validation\ValidationException;
|
|
use Laravel\Fortify\Contracts\ResetsUserPasswords;
|
|
|
|
class ResetUserPassword implements ResetsUserPasswords
|
|
{
|
|
use PasswordValidationRules;
|
|
|
|
/**
|
|
* Validate and reset the user's forgotten password.
|
|
*
|
|
* @param array<string, string> $input
|
|
* @throws ValidationException
|
|
*/
|
|
public function reset(User $user, array $input): void
|
|
{
|
|
Validator::make($input, [
|
|
'password' => $this->passwordRules(),
|
|
])->validate();
|
|
|
|
$user->forceFill([
|
|
'password' => Hash::make($input['password']),
|
|
]);
|
|
|
|
$validatingGroupId = Group::query()->where('slug', '=', 'validating')->soleValue('id');
|
|
|
|
if ($user->group_id === $validatingGroupId) {
|
|
$user->group_id = Group::query()->where('slug', '=', 'user')->soleValue('id');
|
|
|
|
cache()->forget('user:'.$user->passkey);
|
|
|
|
Unit3dAnnounce::addUser($user);
|
|
}
|
|
|
|
if (!$user->hasVerifiedEmail()) {
|
|
$user->markEmailAsVerified();
|
|
}
|
|
|
|
$user->save();
|
|
|
|
$user->passwordResetHistories()->create();
|
|
}
|
|
}
|