Add function to delete users that have not verified their accounts for 3 or more days

This commit is contained in:
DariusIII
2018-06-20 12:43:11 +02:00
parent 1db9665a05
commit 12486ae75e
4 changed files with 22 additions and 3 deletions
+11 -1
View File
@@ -12,6 +12,7 @@ use Illuminate\Support\Facades\Mail;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Password;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Jrean\UserVerification\Traits\UserVerification;
/**
* App\Models\User.
@@ -111,6 +112,7 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
use UserVerification;
public const ERR_SIGNUP_BADUNAME = -1;
public const ERR_SIGNUP_BADPASS = -2;
@@ -1033,7 +1035,7 @@ class User extends Authenticatable
}
/**
* deletes old rows FROM the user_requests and user_downloads tables.
* Deletes old rows FROM the user_requests and user_downloads tables.
* if site->userdownloadpurgedays SET to 0 then all release history is removed but
* the download/request rows must remain for at least one day to allow the role based
* limits to apply.
@@ -1050,4 +1052,12 @@ class User extends Authenticatable
UserRequest::query()->where('timestamp', '<', now()->subDays($days))->delete();
UserDownload::query()->where('timestamp', '<', now()->subDays($days))->delete();
}
/**
* Deletes users that have not verified their accounts for 3 or more days
*/
public static function deleteUnVerified()
{
static::query()->where('verified', '=', 0)->where('created_at', '<', now()->subDays(3))->delete();
}
}