diff --git a/app/Classes/General/Abstracts/AbstractControllerLogic.php b/app/Classes/General/Abstracts/AbstractControllerLogic.php index eca73016..4a0366b2 100644 --- a/app/Classes/General/Abstracts/AbstractControllerLogic.php +++ b/app/Classes/General/Abstracts/AbstractControllerLogic.php @@ -52,7 +52,6 @@ abstract class AbstractControllerLogic return $this->logic($request); } catch (ErrorException $exception){ - dd($exception); return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(), $exception->getCode()))->handler(); } diff --git a/app/Classes/Modules/Accounts/ControllersLogic/AuthenticateUserLogic.php b/app/Classes/Modules/Accounts/ControllersLogic/AuthenticateUserLogic.php index a28df296..9785cbc6 100644 --- a/app/Classes/Modules/Accounts/ControllersLogic/AuthenticateUserLogic.php +++ b/app/Classes/Modules/Accounts/ControllersLogic/AuthenticateUserLogic.php @@ -60,6 +60,7 @@ class AuthenticateUserLogic extends AbstractControllerLogic return $this->response(['access_token' => $token, 'redirect_url' => $this->authenticationRedirect->url()]); } catch (\Exception $exception){ + dd($exception); throw new ErrorException($exception->getMessage(), $exception->getCode()); } diff --git a/app/Classes/Modules/Accounts/ControllersLogic/CreateUserLogic.php b/app/Classes/Modules/Accounts/ControllersLogic/CreateUserLogic.php index d988fe08..7bce7f7e 100644 --- a/app/Classes/Modules/Accounts/ControllersLogic/CreateUserLogic.php +++ b/app/Classes/Modules/Accounts/ControllersLogic/CreateUserLogic.php @@ -121,7 +121,6 @@ class CreateUserLogic extends AbstractControllerLogic return $this->authenticateUserLogic->execute($request); } catch (\Exception $exception){ - dd($exception); throw new ErrorException($exception->getMessage(), $exception->getCode()); } } diff --git a/app/Classes/Modules/Accounts/Services/AuthenticationRedirect.php b/app/Classes/Modules/Accounts/Services/AuthenticationRedirect.php index 2fce8fd6..1dbc05d2 100644 --- a/app/Classes/Modules/Accounts/Services/AuthenticationRedirect.php +++ b/app/Classes/Modules/Accounts/Services/AuthenticationRedirect.php @@ -9,10 +9,13 @@ class AuthenticationRedirect { public function url(){ - $userRole = (int) Auth()->user()->role_id; - return $userRole === Roles::ADMIN || $userRole === Roles::SUPER_ADMIN ? route('company.profile', ['id' => 10]) : route('company.profile', ['id' => 1]); + if($userRole === Roles::ADMIN){ + return route('admin.dashboard'); + } + + return route('company.profile', ['id' => Auth()->user()->employers->first()->company->id]); } diff --git a/app/Models/User.php b/app/Models/User.php index ec6b5d71..955bcc08 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -2,6 +2,7 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; use Tymon\JWTAuth\Contracts\JWTSubject; use Illuminate\Notifications\Notifiable; @@ -49,8 +50,8 @@ class User extends AbstractModel implements return $this->hasMany(PasswordReset::class, 'user_id', 'id'); } - public function employers(): hasMany { - return $this->hasMany(CompanyModule::class); + public function employers(): belongsToMany { + return $this->belongsToMany(CompanyModule::class, (new CompanyEmployee())->getTable(), 'user_id', 'module_id'); } diff --git a/resources/assets/vue/components/authentication/forms/RegistrationFormComponent.vue b/resources/assets/vue/components/authentication/forms/RegistrationFormComponent.vue index 6ad03c18..7cabc5cd 100644 --- a/resources/assets/vue/components/authentication/forms/RegistrationFormComponent.vue +++ b/resources/assets/vue/components/authentication/forms/RegistrationFormComponent.vue @@ -174,15 +174,15 @@