(Update) Group Handling

This commit is contained in:
HDVinnie
2018-09-17 19:09:12 -04:00
parent b251fed922
commit dc0dfd176e
11 changed files with 55 additions and 25 deletions

View File

@@ -42,12 +42,13 @@ class autoBan extends Command
*/
public function handle()
{
$bannedGroup = Group::where('slug', '=', 'banned')->first();
$bans = Warning::with('warneduser')->select(DB::raw('user_id, count(*) as value'))->where('active', 1)->groupBy('user_id')->having('value', '>=', config('hitrun.max_warnings'))->get();
foreach ($bans as $ban) {
if ($ban->warneduser->group_id != 5 && !$ban->warneduser->group->is_immune) {
if ($ban->warneduser->group_id != $bannedGroup->id && !$ban->warneduser->group->is_immune) {
// If User Has x or More Active Warnings Ban Set The Users Group To Banned
$ban->warneduser->group_id = 5;
$ban->warneduser->group_id = $bannedGroup->id;
$ban->warneduser->can_upload = 0;
$ban->warneduser->can_download = 0;
$ban->warneduser->can_comment = 0;

View File

@@ -22,7 +22,7 @@ class ActivationController extends Controller
public function activate($token)
{
$bannedGroup = Group::where('slug', '=', 'banned')->first();
$defaultGroup = Group::where('slug', '=', 'member')->first();
$memberGroup = Group::where('slug', '=', 'member')->first();
$activation = UserActivation::with('user')->where('token', $token)->firstOrFail();
if ($activation->user->id && $activation->user->group->id != $bannedGroup->id) {
@@ -32,7 +32,7 @@ class ActivationController extends Controller
$activation->user->can_request = 1;
$activation->user->can_comment = 1;
$activation->user->can_invite = 1;
$activation->user->group_id = $defaultGroup->id;
$activation->user->group_id = $memberGroup->id;
$activation->user->save();
// Activity Log

View File

@@ -69,6 +69,7 @@ class LoginController extends Controller
$bannedGroup = Group::where('slug', '=', 'banned')->first();
$validatingGroup = Group::where('slug', '=', 'validating')->first();
$disabledGroup = Group::where('slug', '=', 'disabled')->first();
$memberGroup = Group::where('slug', '=', 'member')->first();
if ($user->active == 0 || $user->group_id == $validatingGroup->id) {
auth()->logout();
@@ -85,7 +86,7 @@ class LoginController extends Controller
}
if ($user->group_id == $disabledGroup->id) {
$user->group_id = 3;
$user->group_id = $memberGroup->id;
$user->can_upload = 1;
$user->can_download = 1;
$user->can_comment = 1;

View File

@@ -67,7 +67,7 @@ class RegisterController extends Controller
->with(Toastr::error('Invalid or Expired Invite Key!', 'Whoops!', ['options']));
}
$group = Group::where('slug', '=', 'validating')->first();
$validatingGroup = Group::where('slug', '=', 'validating')->first();
$user = new User();
$user->username = $request->input('username');
$user->email = $request->input('email');
@@ -77,7 +77,7 @@ class RegisterController extends Controller
$user->uploaded = config('other.default_upload');
$user->downloaded = config('other.default_download');
$user->style = config('other.default_style', 0);
$user->group_id = $group->id;
$user->group_id = $validatingGroup->id;
if (config('email-white-blacklist.enabled') === 'allow' && config('captcha.enabled') == true) {
$v = validator($request->all(), [

View File

@@ -12,7 +12,6 @@ class ResetPasswordController extends Controller
use ResetsPasswords;
protected $redirectTo = '/';
protected $group_id = 3;
public function __construct()
{
@@ -21,11 +20,15 @@ class ResetPasswordController extends Controller
protected function resetPassword($user, $password)
{
$validatingGroup = Group::where('slug', '=', 'validating')->first();
$memberGroup = Group::where('slug', '=', 'member')->first();
$user->password = bcrypt($password);
$user->remember_token = Str::random(60);
if ($user->group_id === 1) {
$user->group_id = $this->group_id;
if ($user->group_id === $validatingGroup->id) {
$user->group_id = $memberGroup->id;
}
$user->active = true;
$user->save();

View File

@@ -48,12 +48,13 @@ class BanController extends Controller
{
$user = User::findOrFail($id);
$staff = auth()->user();
$bannedGroup = Group::where('slug', '=', 'banned')->first();
if ($user->group->is_modo || auth()->user()->id == $user->id) {
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
->with(Toastr::error('You Cannot Ban Yourself Or Other Staff!', 'Whoops!', ['options']));
} else {
$user->group_id = 5;
$user->group_id = $bannedGroup->id;
$user->can_upload = 0;
$user->can_download = 0;
$user->can_comment = 0;

View File

@@ -31,9 +31,12 @@ class HomeController extends Controller
public function home()
{
// User Info
$bannedGroup = Group::where('slug', '=', 'banned')->first();
$validatingGroup = Group::where('slug', '=', 'validating')->first();
$num_user = User::all()->count();
$banned = User::where('group_id', 5)->count();
$validating = User::where('group_id', 1)->count();
$banned = User::where('group_id', $bannedGroup->id)->count();
$validating = User::where('group_id', $validatingGroup->id)->count();
// Torrent Info
$num_torrent = Torrent::all()->count();

View File

@@ -278,10 +278,12 @@ class UserController extends Controller
*/
public function massValidateUsers()
{
$users = User::where('active', '=', 0)->where('group_id', '=', 1)->get();
$validatingGroup = Group::where('slug', '=', 'validating')->first();
$memberGroup = Group::where('slug', '=', 'member')->first();
$users = User::where('active', '=', 0)->where('group_id', '=', $validatingGroup->id)->get();
foreach ($users as $user) {
$user->group_id = 3;
$user->group_id = $memberGroup->id;
$user->active = 1;
$user->can_upload = 1;
$user->can_download = 1;

View File

@@ -150,8 +150,13 @@ class StatsController extends Controller
*/
public function uploaded()
{
$validatingGroup = Group::where('slug', '=', 'validating')->first();
$bannedGroup = Group::where('slug', '=', 'banned')->first();
$disabledGroup = Group::where('slug', '=', 'disabled')->first();
$prunedGroup = Group::where('slug', '=', 'pruned')->first();
// Fetch Top Uploaders
$uploaded = User::latest('uploaded')->where('group_id', '!=', 1)->where('group_id', '!=', 5)->take(100)->get();
$uploaded = User::latest('uploaded')->whereNotIn('group_id', [$validatingGroup, $bannedGroup, $disabledGroup, $prunedGroup])->take(100)->get();
return view('stats.users.uploaded', ['uploaded' => $uploaded]);
}
@@ -163,8 +168,13 @@ class StatsController extends Controller
*/
public function downloaded()
{
$validatingGroup = Group::where('slug', '=', 'validating')->first();
$bannedGroup = Group::where('slug', '=', 'banned')->first();
$disabledGroup = Group::where('slug', '=', 'disabled')->first();
$prunedGroup = Group::where('slug', '=', 'pruned')->first();
// Fetch Top Downloaders
$downloaded = User::latest('downloaded')->where('group_id', '!=', 1)->where('group_id', '!=', 5)->take(100)->get();
$downloaded = User::latest('downloaded')->whereNotIn('group_id', [$validatingGroup, $bannedGroup, $disabledGroup, $prunedGroup])->take(100)->get();
return view('stats.users.downloaded', ['downloaded' => $downloaded]);
}
@@ -215,8 +225,13 @@ class StatsController extends Controller
*/
public function bankers()
{
$validatingGroup = Group::where('slug', '=', 'validating')->first();
$bannedGroup = Group::where('slug', '=', 'banned')->first();
$disabledGroup = Group::where('slug', '=', 'disabled')->first();
$prunedGroup = Group::where('slug', '=', 'pruned')->first();
// Fetch Top Bankers
$bankers = User::latest('seedbonus')->where('group_id', '!=', 1)->where('group_id', '!=', 5)->take(100)->get();
$bankers = User::latest('seedbonus')->whereNotIn('group_id', [$validatingGroup, $bannedGroup, $disabledGroup, $prunedGroup])->take(100)->get();
return view('stats.users.bankers', ['bankers' => $bankers]);
}

View File

@@ -28,12 +28,13 @@ class CheckIfActive
public function handle($request, Closure $next, $guard = null)
{
$user = auth()->user();
if ($user and $user->group_id == 1 || $user->active == 0) {
$validatingGroup = Group::where('slug', '=', 'validating')->first();
if ($user && $user->group_id == $validatingGroup || $user->active == 0) {
auth()->logout();
$request->session()->flush();
return redirect('login')
->with(Toastr::warning('This account has not been activated and is still in validating group, Please check your email for activation link. If you did not receive the activation code, please click "forgot password" and complete the steps.', 'Whoops!', ['options']));
;
}
return $next($request);

View File

@@ -20,18 +20,21 @@ class CheckIfBanned
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
$user = auth()->user();
if ($user and $user->group_id == 5) {
$bannedGroup = Group::where('slug', '=', 'banned')->first();
if ($user && $user->group_id == $bannedGroup) {
auth()->logout();
$request->session()->flush();
return redirect('login')->with(Toastr::error('This account is Banned!', 'Whoops!', ['options']));
return redirect('login')
->with(Toastr::error('This account is Banned!', 'Whoops!', ['options']));
}
return $next($request);