Files
UNIT3D-Community-Edition/app/Http/Controllers/Auth/ResetPasswordController.php
HDVinnie 80c842e39c chore: update license block
- make styleci happy
2020-02-12 14:49:18 -05:00

58 lines
1.6 KiB
PHP
Executable File

<?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 $redirectTo = '/';
public function __construct()
{
$this->middleware('guest');
}
protected function resetPassword($user, $password)
{
$validating_group = cache()->rememberForever('validating_group', function () {
return Group::where('slug', '=', 'validating')->pluck('id');
});
$member_group = cache()->rememberForever('member_group', function () {
return Group::where('slug', '=', 'user')->pluck('id');
});
$user->password = bcrypt($password);
$user->remember_token = Str::random(60);
if ($user->group_id === $validating_group[0]) {
$user->group_id = $member_group[0];
}
$user->active = true;
$user->save();
UserActivation::where('user_id', '=', $user->id)->delete();
$this->guard()->login($user);
}
}