@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | public function loginUrl($handle, $options = []) |
73 | 73 | { |
74 | 74 | $provider = $this->getProviderByHandle($handle); |
75 | - if (is_null($provider)){ |
|
75 | + if (is_null($provider)) { |
|
76 | 76 | throw new NotSupportedException('Provider not found or disabled: '.$handle); |
77 | 77 | } |
78 | 78 | |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | ]]; |
140 | 140 | |
141 | 141 | foreach ($fields as $field) { |
142 | - if (!$this->validateFieldClass($field)){ |
|
142 | + if (!$this->validateFieldClass($field)) { |
|
143 | 143 | continue; |
144 | 144 | } |
145 | 145 | |
146 | 146 | $option = [ |
147 | - 'label' => $field->name. ' ('.$field->handle.')', |
|
147 | + 'label' => $field->name.' ('.$field->handle.')', |
|
148 | 148 | 'value' => $field->handle |
149 | 149 | ]; |
150 | 150 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | Dropdown::class => 1 |
168 | 168 | ]; |
169 | 169 | |
170 | - if (isset($supportedClasses[$fieldClass])){ |
|
170 | + if (isset($supportedClasses[$fieldClass])) { |
|
171 | 171 | return true; |
172 | 172 | } |
173 | 173 | |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | { |
382 | 382 | $providers = $this->getAllProviderTypes(); |
383 | 383 | |
384 | - if ($excludeCreated){ |
|
384 | + if ($excludeCreated) { |
|
385 | 385 | $providers = $this->getExcludeCreatedProviders(); |
386 | 386 | } |
387 | 387 | |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | $adapter = $provider->getAdapter(); |
574 | 574 | try { |
575 | 575 | $adapter->authenticate(); |
576 | - } catch (\Exception $e){ |
|
576 | + } catch (\Exception $e) { |
|
577 | 577 | Craft::error("Unable to Authorize user", __METHOD__); |
578 | 578 | return false; |
579 | 579 | } |
@@ -581,11 +581,11 @@ discard block |
||
581 | 581 | $userProfile = $adapter->getUserProfile(); |
582 | 582 | $user = Craft::$app->getUser()->getIdentity(); |
583 | 583 | |
584 | - if (!$user){ |
|
584 | + if (!$user) { |
|
585 | 585 | $user = $this->retrieveUser($userProfile, $provider); |
586 | 586 | } |
587 | 587 | |
588 | - if (!$user){ |
|
588 | + if (!$user) { |
|
589 | 589 | Craft::error("Not user to login", __METHOD__); |
590 | 590 | return false; |
591 | 591 | } |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | */ |
613 | 613 | private function retrieveUser(Profile $userProfile, Provider $provider): User |
614 | 614 | { |
615 | - if (is_null($userProfile->email)){ |
|
615 | + if (is_null($userProfile->email)) { |
|
616 | 616 | throw new \Exception("Email address is not provided, please check the settings of your application"); |
617 | 617 | } |
618 | 618 | |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | } |
624 | 624 | $settings = Socializer::$app->settings->getSettings(); |
625 | 625 | |
626 | - if (!$settings->enableUserSignUp){ |
|
626 | + if (!$settings->enableUserSignUp) { |
|
627 | 627 | return null; |
628 | 628 | } |
629 | 629 | |
@@ -637,14 +637,14 @@ discard block |
||
637 | 637 | // validate populate |
638 | 638 | $user = $this->populateUserModel($user, $provider, $userProfile); |
639 | 639 | |
640 | - if (!Craft::$app->elements->saveElement($user)){ |
|
640 | + if (!Craft::$app->elements->saveElement($user)) { |
|
641 | 641 | Craft::error("Unable to create user: ".json_encode($user->getErrors())); |
642 | 642 | throw new \Exception("Something went wrong while creating the user"); |
643 | 643 | } |
644 | 644 | |
645 | - if ($settings->userGroupId){ |
|
645 | + if ($settings->userGroupId) { |
|
646 | 646 | $userGroup = Craft::$app->getUserGroups()->getGroupById($settings->userGroupId); |
647 | - if ($userGroup){ |
|
647 | + if ($userGroup) { |
|
648 | 648 | Craft::$app->getUsers()->assignUserToGroups($user->id, [$userGroup->id]); |
649 | 649 | } |
650 | 650 | } |
@@ -673,10 +673,10 @@ discard block |
||
673 | 673 | } |
674 | 674 | |
675 | 675 | foreach ($fieldMapping as $item) { |
676 | - if(isset($item['targetUserField']) && $item['targetUserField']){ |
|
676 | + if (isset($item['targetUserField']) && $item['targetUserField']) { |
|
677 | 677 | $profileValue = $profile->{$item['sourceFormField']}; |
678 | 678 | $field = $user->getFieldLayout()->getFieldByHandle($item['targetUserField']); |
679 | - if ($field){ |
|
679 | + if ($field) { |
|
680 | 680 | $user->setFieldValue($item['targetUserField'], $profileValue); |
681 | 681 | } |
682 | 682 | } |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | $providerRecord = ProviderRecord::findOne($provider->id); |
700 | 700 | |
701 | 701 | if (!$providerRecord) { |
702 | - throw new Exception(Craft::t("enupal-socializer",'No Provider exists with the ID “{id}”', ['id' => $provider->id])); |
|
702 | + throw new Exception(Craft::t("enupal-socializer", 'No Provider exists with the ID “{id}”', ['id' => $provider->id])); |
|
703 | 703 | } |
704 | 704 | } |
705 | 705 |
@@ -45,8 +45,7 @@ |
||
45 | 45 | Craft::$app->getSession()->setError(Craft::t('enupal-socializer', "Unable to authenticate user")); |
46 | 46 | } |
47 | 47 | } |
48 | - } |
|
49 | - catch (\Exception $e) { |
|
48 | + } catch (\Exception $e) { |
|
50 | 49 | Craft::error($e->getMessage(), __METHOD__); |
51 | 50 | } |
52 | 51 |