Skip to content

Commit

Permalink
refact: social login company
Browse files Browse the repository at this point in the history
  • Loading branch information
kaioken committed Jul 31, 2024
1 parent fa2dab6 commit 3757e32
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Kanvas/Auth/Actions/SocialLoginAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use Kanvas\Apps\Models\Apps;
use Kanvas\Auth\DataTransferObject\RegisterInput;
use Kanvas\Auth\Socialite\DataTransferObject\User as SocialiteUser;
use Kanvas\Companies\Models\CompaniesBranches;
use Kanvas\Enums\AppSettingsEnums;
use Kanvas\Users\Models\Sources;
use Kanvas\Users\Models\UserLinkedSources;
use Kanvas\Users\Models\Users;
Expand Down Expand Up @@ -47,7 +49,14 @@ public function execute(): Users
'password' => Str::random(11),
'displayname' => $this->socialUser->nickname,
];
$userData = RegisterInput::fromArray($userData);

$userRegistrationAssignToAppDefaultCompanyBranch = $this->app->get(AppSettingsEnums::GLOBAL_USER_REGISTRATION_ASSIGN_GLOBAL_COMPANY->getValue());
$branch = null;
if ($userRegistrationAssignToAppDefaultCompanyBranch) {
$branch = CompaniesBranches::getById($userRegistrationAssignToAppDefaultCompanyBranch);
}

$userData = RegisterInput::fromArray($userData, $branch);

$registeredUser = new RegisterUsersAction($userData, $this->app);
$existedUser = $registeredUser->execute();
Expand Down

0 comments on commit 3757e32

Please sign in to comment.