@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | public function loginUrl($handle, $options = []) |
| 153 | 153 | { |
| 154 | 154 | $provider = $this->getProviderByHandle($handle); |
| 155 | - if (is_null($provider)){ |
|
| 155 | + if (is_null($provider)) { |
|
| 156 | 156 | throw new NotSupportedException('Provider not found or disabled: '.$handle); |
| 157 | 157 | } |
| 158 | 158 | |
@@ -219,12 +219,12 @@ discard block |
||
| 219 | 219 | ]]; |
| 220 | 220 | |
| 221 | 221 | foreach ($fields as $field) { |
| 222 | - if (!$this->validateFieldClass($field)){ |
|
| 222 | + if (!$this->validateFieldClass($field)) { |
|
| 223 | 223 | continue; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | $option = [ |
| 227 | - 'label' => $field->name. ' ('.$field->handle.')', |
|
| 227 | + 'label' => $field->name.' ('.$field->handle.')', |
|
| 228 | 228 | 'value' => $field->handle |
| 229 | 229 | ]; |
| 230 | 230 | |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | Dropdown::class => 1 |
| 248 | 248 | ]; |
| 249 | 249 | |
| 250 | - if (isset($supportedClasses[$fieldClass])){ |
|
| 250 | + if (isset($supportedClasses[$fieldClass])) { |
|
| 251 | 251 | return true; |
| 252 | 252 | } |
| 253 | 253 | |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | { |
| 462 | 462 | $providers = $this->getAllProviderTypes(); |
| 463 | 463 | |
| 464 | - if ($excludeCreated){ |
|
| 464 | + if ($excludeCreated) { |
|
| 465 | 465 | $providers = $this->getExcludeCreatedProviders(); |
| 466 | 466 | } |
| 467 | 467 | |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | $adapter = $provider->getAdapter(); |
| 654 | 654 | try { |
| 655 | 655 | $adapter->authenticate(); |
| 656 | - } catch (\Exception $e){ |
|
| 656 | + } catch (\Exception $e) { |
|
| 657 | 657 | Craft::error("Unable to Authorize user", __METHOD__); |
| 658 | 658 | return false; |
| 659 | 659 | } |
@@ -661,11 +661,11 @@ discard block |
||
| 661 | 661 | $userProfile = $adapter->getUserProfile(); |
| 662 | 662 | $user = Craft::$app->getUser()->getIdentity(); |
| 663 | 663 | |
| 664 | - if (!$user){ |
|
| 664 | + if (!$user) { |
|
| 665 | 665 | $user = $this->retrieveUser($userProfile, $provider); |
| 666 | 666 | } |
| 667 | 667 | |
| 668 | - if (!$user){ |
|
| 668 | + if (!$user) { |
|
| 669 | 669 | Craft::error("Not user to login", __METHOD__); |
| 670 | 670 | return false; |
| 671 | 671 | } |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | |
| 675 | 675 | $user = $this->triggerBeforeLoginUser($user, $provider, $userProfile); |
| 676 | 676 | |
| 677 | - if (is_null($user)){ |
|
| 677 | + if (is_null($user)) { |
|
| 678 | 678 | Craft::error("User not valid to login on BeforeLoginEvent", __METHOD__); |
| 679 | 679 | return false; |
| 680 | 680 | } |
@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | */ |
| 731 | 731 | private function retrieveUser(Profile $userProfile, Provider $provider): User |
| 732 | 732 | { |
| 733 | - if (is_null($userProfile->email)){ |
|
| 733 | + if (is_null($userProfile->email)) { |
|
| 734 | 734 | throw new \Exception("Email address is not provided, please check the settings of your application"); |
| 735 | 735 | } |
| 736 | 736 | |
@@ -741,7 +741,7 @@ discard block |
||
| 741 | 741 | } |
| 742 | 742 | $settings = Socializer::$app->settings->getSettings(); |
| 743 | 743 | |
| 744 | - if (!$settings->enableUserSignUp){ |
|
| 744 | + if (!$settings->enableUserSignUp) { |
|
| 745 | 745 | return null; |
| 746 | 746 | } |
| 747 | 747 | |
@@ -769,14 +769,14 @@ discard block |
||
| 769 | 769 | return null; |
| 770 | 770 | } |
| 771 | 771 | |
| 772 | - if (!Craft::$app->elements->saveElement($user)){ |
|
| 772 | + if (!Craft::$app->elements->saveElement($user)) { |
|
| 773 | 773 | Craft::error("Unable to create user: ".json_encode($user->getErrors())); |
| 774 | 774 | throw new \Exception("Something went wrong while creating the user"); |
| 775 | 775 | } |
| 776 | 776 | |
| 777 | - if ($settings->userGroupId){ |
|
| 777 | + if ($settings->userGroupId) { |
|
| 778 | 778 | $userGroup = Craft::$app->getUserGroups()->getGroupById($settings->userGroupId); |
| 779 | - if ($userGroup){ |
|
| 779 | + if ($userGroup) { |
|
| 780 | 780 | Craft::$app->getUsers()->assignUserToGroups($user->id, [$userGroup->id]); |
| 781 | 781 | } |
| 782 | 782 | } |
@@ -818,10 +818,10 @@ discard block |
||
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | foreach ($fieldMapping as $item) { |
| 821 | - if(isset($item['targetUserField']) && $item['targetUserField']){ |
|
| 821 | + if (isset($item['targetUserField']) && $item['targetUserField']) { |
|
| 822 | 822 | $profileValue = $profile->{$item['sourceFormField']}; |
| 823 | 823 | $field = $user->getFieldLayout()->getFieldByHandle($item['targetUserField']); |
| 824 | - if ($field){ |
|
| 824 | + if ($field) { |
|
| 825 | 825 | $user->setFieldValue($item['targetUserField'], $profileValue); |
| 826 | 826 | } |
| 827 | 827 | } |
@@ -844,7 +844,7 @@ discard block |
||
| 844 | 844 | $providerRecord = ProviderRecord::findOne($provider->id); |
| 845 | 845 | |
| 846 | 846 | if (!$providerRecord) { |
| 847 | - throw new Exception(Craft::t("enupal-socializer",'No Provider exists with the ID “{id}”', ['id' => $provider->id])); |
|
| 847 | + throw new Exception(Craft::t("enupal-socializer", 'No Provider exists with the ID “{id}”', ['id' => $provider->id])); |
|
| 848 | 848 | } |
| 849 | 849 | } |
| 850 | 850 | |