fix: use Auth(), add new db proxy stop event refactor clickhouse view
This commit is contained in:
@@ -10,6 +10,7 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
@@ -158,7 +159,7 @@ class User extends Authenticatable implements SendsEmail
|
||||
|
||||
public function isAdminFromSession()
|
||||
{
|
||||
if (auth()->user()->id === 0) {
|
||||
if (Auth::id() === 0) {
|
||||
return true;
|
||||
}
|
||||
$teams = $this->teams()->get();
|
||||
@@ -178,9 +179,9 @@ class User extends Authenticatable implements SendsEmail
|
||||
|
||||
public function isInstanceAdmin()
|
||||
{
|
||||
$found_root_team = auth()->user()->teams->filter(function ($team) {
|
||||
$found_root_team = Auth::user()->teams->filter(function ($team) {
|
||||
if ($team->id == 0) {
|
||||
if (! auth()->user()->isAdmin()) {
|
||||
if (! Auth::user()->isAdmin()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -195,9 +196,9 @@ 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')) && auth()->user()->teams->count() > 0) {
|
||||
return auth()->user()->teams[0];
|
||||
return Cache::remember('team:'.Auth::id(), 3600, function () {
|
||||
if (is_null(data_get(session('currentTeam'), 'id')) && Auth::user()->teams->count() > 0) {
|
||||
return Auth::user()->teams[0];
|
||||
}
|
||||
|
||||
return Team::find(session('currentTeam')->id);
|
||||
@@ -206,7 +207,7 @@ class User extends Authenticatable implements SendsEmail
|
||||
|
||||
public function otherTeams()
|
||||
{
|
||||
return auth()->user()->teams->filter(function ($team) {
|
||||
return Auth::user()->teams->filter(function ($team) {
|
||||
return $team->id != currentTeam()->id;
|
||||
});
|
||||
}
|
||||
@@ -216,7 +217,7 @@ class User extends Authenticatable implements SendsEmail
|
||||
if (data_get($this, 'pivot')) {
|
||||
return $this->pivot->role;
|
||||
}
|
||||
$user = auth()->user()->teams->where('id', currentTeam()->id)->first();
|
||||
$user = Auth::user()->teams->where('id', currentTeam()->id)->first();
|
||||
|
||||
return data_get($user, 'pivot.role');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user