Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Fix condition to return current team if user has teams

Andras Bacsai9c1d585c43ab
diff --git a/app/Models/User.php b/app/Models/User.php
index 9581d1fa50..d6389d6782 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -158,7 +158,7 @@ class User extends Authenticatable implements SendsEmail
public function currentTeam()
{
return Cache::remember('team:' . auth()->user()->id, 3600, function () {
- if (is_null(data_get(session('currentTeam'), 'id'))) {
+ if (is_null(data_get(session('currentTeam'), 'id')) && auth()->user()->teams->count() > 0){
return auth()->user()->teams[0];
}
return Team::find(session('currentTeam')->id);