mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-01-21 03:21:38 -06:00
52 lines
1.5 KiB
PHP
52 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* 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\Http\Controllers\Auth;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Group;
|
|
use App\Models\UserActivation;
|
|
use Illuminate\Foundation\Auth\ResetsPasswords;
|
|
use Illuminate\Support\Str;
|
|
|
|
class ResetPasswordController extends Controller
|
|
{
|
|
use ResetsPasswords;
|
|
|
|
protected string $redirectTo = '/';
|
|
|
|
public function __construct()
|
|
{
|
|
$this->middleware('guest');
|
|
}
|
|
|
|
protected function resetPassword($user, $password): void
|
|
{
|
|
$validatingGroup = \cache()->rememberForever('validating_group', fn () => Group::where('slug', '=', 'validating')->pluck('id'));
|
|
$memberGroup = \cache()->rememberForever('member_group', fn () => Group::where('slug', '=', 'user')->pluck('id'));
|
|
$user->password = \bcrypt($password);
|
|
$user->remember_token = Str::random(60);
|
|
|
|
if ($user->group_id === $validatingGroup[0]) {
|
|
$user->group_id = $memberGroup[0];
|
|
}
|
|
|
|
$user->active = true;
|
|
$user->save();
|
|
|
|
UserActivation::where('user_id', '=', $user->id)->delete();
|
|
|
|
$this->guard()->login($user);
|
|
}
|
|
}
|