Files
UNIT3D-Community-Edition/app/Http/Controllers/Auth/ResetPasswordController.php
HDVinnie 0bece18c5c (Update) Group Queries 🚀
- add caching to system required groups
2019-11-20 12:11:41 -05:00

57 lines
1.5 KiB
PHP
Executable File

<?php
/**
* NOTICE OF LICENSE.
*
* UNIT3D 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
*
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
* @author HDVinnie
*/
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);
}
}