mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-18 17:20:42 +00:00
Changes auto-committed by Conductor
This commit is contained in:
@@ -338,6 +338,39 @@ class User extends Authenticatable implements SendsEmail
|
||||
return data_get($user, 'pivot.role');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the user is an admin or owner of a specific team
|
||||
*/
|
||||
public function isAdminOfTeam(int $teamId): bool
|
||||
{
|
||||
$team = $this->teams->where('id', $teamId)->first();
|
||||
|
||||
if (! $team) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$role = $team->pivot->role ?? null;
|
||||
|
||||
return $role === 'admin' || $role === 'owner';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the user can access system resources (team_id=0)
|
||||
* Must be admin/owner of root team
|
||||
*/
|
||||
public function canAccessSystemResources(): bool
|
||||
{
|
||||
// Check if user is member of root team
|
||||
$rootTeam = $this->teams->where('id', 0)->first();
|
||||
|
||||
if (! $rootTeam) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if user is admin or owner of root team
|
||||
return $this->isAdminOfTeam(0);
|
||||
}
|
||||
|
||||
public function requestEmailChange(string $newEmail): void
|
||||
{
|
||||
// Generate 6-digit code
|
||||
|
||||
Reference in New Issue
Block a user