Save workspace changes

This commit is contained in:
2026-04-18 17:02:56 +02:00
parent f02ea9a711
commit 87d60af5a9
4220 changed files with 1388603 additions and 1554 deletions

View File

@@ -29,6 +29,11 @@ use Laravel\Scout\Searchable;
class User extends Authenticatable
{
private const EMAIL_LOGIN_UPGRADE_PLACEHOLDER_DOMAINS = [
'users.skinbase.org',
'legacy.skinbase.org',
];
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory, Notifiable, SoftDeletes;
use Searchable {
@@ -114,6 +119,40 @@ class User extends Authenticatable
];
}
public function hasCompletedOnboarding(): bool
{
return strtolower(trim((string) ($this->onboarding_step ?? ''))) === 'complete';
}
public function requiresEmailLoginUpgrade(): bool
{
return ! $this->hasCompletedOnboarding()
&& self::isEmailLoginUpgradePlaceholder($this->email);
}
public static function isEmailLoginUpgradePlaceholder(?string $email): bool
{
$email = strtolower(trim((string) ($email ?? '')));
if ($email === '') {
return true;
}
$atPos = strrpos($email, '@');
if ($atPos === false) {
return true;
}
$domain = substr($email, $atPos + 1);
return in_array($domain, self::EMAIL_LOGIN_UPGRADE_PLACEHOLDER_DOMAINS, true);
}
public function supportsUsernameLogin(): bool
{
return ! $this->hasCompletedOnboarding();
}
public function novaCards(): HasMany
{
return $this->hasMany(NovaCard::class);
@@ -297,6 +336,15 @@ class User extends Authenticatable
return strtolower((string) ($this->role ?? '')) === strtolower($role);
}
private function hasLegacyPrivilegeFlag(string $attribute): bool
{
if (! array_key_exists($attribute, $this->getAttributes())) {
return false;
}
return (bool) $this->getAttribute($attribute);
}
// ─── Follow helpers ───────────────────────────────────────────────────────
/**
@@ -334,12 +382,12 @@ class User extends Authenticatable
public function isAdmin(): bool
{
return $this->hasRole('admin');
return $this->hasRole('admin') || $this->hasLegacyPrivilegeFlag('isAdmin');
}
public function isModerator(): bool
{
return $this->hasRole('moderator');
return $this->hasRole('moderator') || $this->hasLegacyPrivilegeFlag('isModerator');
}
public function posts(): HasMany