(Update) Invite System Enhancements

- Closes #248
- Ability to set invite expire time in config/other.php
- Daily command to recycle old expired invites that were never used
This commit is contained in:
HDVinnie
2018-03-31 14:51:17 -04:00
parent 11263820d3
commit 53af9b5e0a
5 changed files with 57 additions and 4 deletions
+49
View File
@@ -0,0 +1,49 @@
<?php
/**
* NOTICE OF LICENSE
*
* UNIT3D is open-sourced software licensed under the GNU 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\Console\Commands;
use Illuminate\Console\Command;
use App\Invite;
use Carbon\Carbon;
class recycleInvites extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'recycleInvites';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Recycle invites that are expired.';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$current = Carbon::now();
$invites = Invite::whereNull('accepted_by')->whereNull('accepted_at')->where('expires_on', '<', $current)->get();
foreach ($invites as $invite) {
$invite->delete();
}
}
}
+2
View File
@@ -29,6 +29,7 @@ class Kernel extends ConsoleKernel
\App\Console\Commands\autoGraveyard::class,
\App\Console\Commands\ircBroadcast::class,
\App\Console\Commands\ircMessage::class,
\App\Console\Commands\recycleInvites::class,
];
/**
@@ -52,6 +53,7 @@ class Kernel extends ConsoleKernel
$schedule->command('removePersonalFreeleech')->hourly();
$schedule->command('removeFeaturedTorrent')->hourly();
$schedule->command('autoGraveyard')->daily();
$schedule->command('recycleInvites')->daily();
}
/**
@@ -35,6 +35,9 @@ class RegisterController extends Controller
{
public function register(Request $request, $code = null)
{
$current = Carbon::now();
$user = new User();
// Make sure open reg is off and ivite code exsists and is not used or expired
if (config('other.invite-only') == true && $code == null) {
return view('auth.login')->with(Toastr::error('Open Reg Closed! You Must Be Invited To Register!', 'Whoops!', ['options']));
@@ -46,9 +49,6 @@ class RegisterController extends Controller
return view('auth.register', ['code' => $code])->with(Toastr::error('Invalid or Expired Invite Key!', 'Whoops!', ['options']));
}
$current = Carbon::now();
$user = new User();
$v = validator($request->all(), [
'username' => 'required|alpha_dash|min:3|max:20|unique:users',
'email' => 'required|email|max:255|unique:users',
+1 -1
View File
@@ -60,7 +60,7 @@ class InviteController extends Controller
'user_id' => $user->id,
'email' => $request->input('email'),
'code' => $code,
'expires_on' => $current->copy()->addDays(14),
'expires_on' => $current->copy()->addDays(config('other.invite_expire')),
'custom' => $request->input('message'),
]);
+2
View File
@@ -126,9 +126,11 @@ return [
|--------------------------------------------------------------------------
|
| Invite System On/Off (Open Reg / Closed)
| Expire time in days
|
*/
'invite-only' => true,
'invite_expire' => '14',
/*
|--------------------------------------------------------------------------