]> BookStack Code Mirror - bookstack/blobdiff - app/Auth/Access/RegistrationService.php
Fixes for CodeStyle vol.2
[bookstack] / app / Auth / Access / RegistrationService.php
index 68b17771d628552fe57a1d40fe7301774d43adb9..16e3edbb44e8dc799c4bd3939a358d5d3b9b28df 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Auth\Access;
+<?php
+
+namespace BookStack\Auth\Access;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Auth\SocialAccount;
@@ -12,7 +14,6 @@ use Exception;
 
 class RegistrationService
 {
-
     protected $userRepo;
     protected $emailConfirmationService;
 
@@ -27,6 +28,7 @@ class RegistrationService
 
     /**
      * Check whether or not registrations are allowed in the app settings.
+     *
      * @throws UserRegistrationException
      */
     public function ensureRegistrationAllowed()
@@ -44,11 +46,13 @@ class RegistrationService
     {
         $authMethod = config('auth.method');
         $authMethodsWithRegistration = ['standard'];
+
         return in_array($authMethod, $authMethodsWithRegistration) && setting('registration-enabled');
     }
 
     /**
      * The registrations flow for all users.
+     *
      * @throws UserRegistrationException
      */
     public function registerUser(array $userData, ?SocialAccount $socialAccount = null, bool $emailConfirmed = false): User
@@ -84,6 +88,7 @@ class RegistrationService
                 session()->flash('sent-email-confirmation', true);
             } catch (Exception $e) {
                 $message = trans('auth.email_confirm_send_error');
+
                 throw new UserRegistrationException($message, '/register/confirm');
             }
         }
@@ -94,6 +99,7 @@ class RegistrationService
     /**
      * Ensure that the given email meets any active email domain registration restrictions.
      * Throws if restrictions are active and the email does not match an allowed domain.
+     *
      * @throws UserRegistrationException
      */
     protected function ensureEmailDomainAllowed(string $userEmail): void
@@ -105,9 +111,10 @@ class RegistrationService
         }
 
         $restrictedEmailDomains = explode(',', str_replace(' ', '', $registrationRestrict));
-        $userEmailDomain = $domain = mb_substr(mb_strrchr($userEmail, "@"), 1);
+        $userEmailDomain = $domain = mb_substr(mb_strrchr($userEmail, '@'), 1);
         if (!in_array($userEmailDomain, $restrictedEmailDomains)) {
             $redirect = $this->registrationAllowed() ? '/register' : '/login';
+
             throw new UserRegistrationException(trans('auth.registration_email_domain_invalid'), $redirect);
         }
     }