mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-03 05:19:37 +00:00
Changes auto-committed by Conductor
This commit is contained in:
1 parent
691fdffa8b
commit
f7427fdea0
8 files changed
+334
-37
No files matched your search
@@ -82,9 +82,10 @@ class PrivateKey extends BaseModel
|
||||
|
||||
public static function ownedByCurrentTeam(array $select = ['*'])
|
||||
{
|
||||
$teamId = currentTeam()->id;
|
||||
$selectArray = collect($select)->concat(['id']);
|
||||
|
||||
return self::whereTeamId(currentTeam()->id)->select($selectArray->all());
|
||||
return self::whereTeamId($teamId)->select($selectArray->all());
|
||||
}
|
||||
|
||||
public static function validatePrivateKey($privateKey)
|
||||
|
||||
@@ -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