mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-26 00:03:16 +00:00
Add user suspend commands
This commit is contained in:
parent
531e600abb
commit
64f683a70a
2 changed files with 112 additions and 0 deletions
56
app/Console/Commands/UserSuspend.php
Normal file
56
app/Console/Commands/UserSuspend.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\User;
|
||||
|
||||
class UserSuspend extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'user:suspend {id}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Suspend a local user.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$id = $this->argument('id');
|
||||
$user = User::whereUsername($id)->orWhere('id', $id)->first();
|
||||
if(!$user) {
|
||||
$this->error('Could not find any user with that username or id.');
|
||||
exit;
|
||||
}
|
||||
$this->info('Found user, username: ' . $user->username);
|
||||
if($this->confirm('Are you sure you want to suspend this user?')) {
|
||||
$profile = $user->profile;
|
||||
$user->status = $profile->status = 'suspended';
|
||||
$user->save();
|
||||
$profile->save();
|
||||
$this->info('User account has been suspended.');
|
||||
}
|
||||
}
|
||||
}
|
56
app/Console/Commands/UserUnsuspend.php
Normal file
56
app/Console/Commands/UserUnsuspend.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\User;
|
||||
|
||||
class UserUnsuspend extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'user:unsuspend {id}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Unsuspend a local user.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$id = $this->argument('id');
|
||||
$user = User::whereUsername($id)->orWhere('id', $id)->first();
|
||||
if(!$user) {
|
||||
$this->error('Could not find any user with that username or id.');
|
||||
exit;
|
||||
}
|
||||
$this->info('Found user, username: ' . $user->username);
|
||||
if($this->confirm('Are you sure you want to unsuspend this user?')) {
|
||||
$profile = $user->profile;
|
||||
$user->status = $profile->status = null;
|
||||
$user->save();
|
||||
$profile->save();
|
||||
$this->info('User account has been unsuspended.');
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue