mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-26 01:36:43 +00:00
Merge pull request #736 from pixelfed/frontend-ui-refactor
Frontend ui refactor
This commit is contained in:
commit
d3b3ef49fd
2 changed files with 27 additions and 9 deletions
|
@ -5,6 +5,7 @@ namespace App\Console\Commands;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use App\{Profile, User};
|
use App\{Profile, User};
|
||||||
use DB;
|
use DB;
|
||||||
|
use App\Util\Lexer\RestrictedNames;
|
||||||
|
|
||||||
class FixUsernames extends Command
|
class FixUsernames extends Command
|
||||||
{
|
{
|
||||||
|
@ -43,8 +44,13 @@ class FixUsernames extends Command
|
||||||
|
|
||||||
$affected = collect([]);
|
$affected = collect([]);
|
||||||
|
|
||||||
$users = User::chunk(100, function($users) use($affected) {
|
$restricted = RestrictedNames::get();
|
||||||
|
|
||||||
|
$users = User::chunk(100, function($users) use($affected, $restricted) {
|
||||||
foreach($users as $user) {
|
foreach($users as $user) {
|
||||||
|
if(in_array($user->username, $restricted)) {
|
||||||
|
$affected->push($user);
|
||||||
|
}
|
||||||
$val = str_replace(['-', '_'], '', $user->username);
|
$val = str_replace(['-', '_'], '', $user->username);
|
||||||
if(!ctype_alnum($val)) {
|
if(!ctype_alnum($val)) {
|
||||||
$this->info('Found invalid username: ' . $user->username);
|
$this->info('Found invalid username: ' . $user->username);
|
||||||
|
@ -58,11 +64,13 @@ class FixUsernames extends Command
|
||||||
$opts = [
|
$opts = [
|
||||||
'Random replace (assigns random username)',
|
'Random replace (assigns random username)',
|
||||||
'Best try replace (assigns alpha numeric username)',
|
'Best try replace (assigns alpha numeric username)',
|
||||||
'Manual replace (manually set username)'
|
'Manual replace (manually set username)',
|
||||||
|
'Skip (do not replace. Use at your own risk)'
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach($affected as $u) {
|
foreach($affected as $u) {
|
||||||
$old = $u->username;
|
$old = $u->username;
|
||||||
|
$this->info("Found user: {$old}");
|
||||||
$opt = $this->choice('Select fix method:', $opts, 0);
|
$opt = $this->choice('Select fix method:', $opts, 0);
|
||||||
|
|
||||||
switch ($opt) {
|
switch ($opt) {
|
||||||
|
@ -83,23 +91,31 @@ class FixUsernames extends Command
|
||||||
$new = $this->ask('Enter new username:');
|
$new = $this->ask('Enter new username:');
|
||||||
$this->info('New username: ' . $new);
|
$this->info('New username: ' . $new);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case $opts[3]:
|
||||||
|
$new = false;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$new = "user_" . str_random(6);
|
$new = "user_" . str_random(6);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::transaction(function() use($u, $new) {
|
if($new) {
|
||||||
$profile = $u->profile;
|
DB::transaction(function() use($u, $new) {
|
||||||
$profile->username = $new;
|
$profile = $u->profile;
|
||||||
$u->username = $new;
|
$profile->username = $new;
|
||||||
$u->save();
|
$u->username = $new;
|
||||||
$profile->save();
|
$u->save();
|
||||||
});
|
$profile->save();
|
||||||
|
});
|
||||||
|
}
|
||||||
$this->info('Selected: ' . $opt);
|
$this->info('Selected: ' . $opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->info('Fixed ' . $affected->count() . ' usernames!');
|
$this->info('Fixed ' . $affected->count() . ' usernames!');
|
||||||
|
} else {
|
||||||
|
$this->info('No affected usernames found!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,6 +171,8 @@ class RestrictedNames
|
||||||
'tour',
|
'tour',
|
||||||
'user',
|
'user',
|
||||||
'users',
|
'users',
|
||||||
|
'username',
|
||||||
|
'usernames',
|
||||||
'vendor',
|
'vendor',
|
||||||
'ws',
|
'ws',
|
||||||
'wss',
|
'wss',
|
||||||
|
|
Loading…
Reference in a new issue