X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fuser%2Fguest%2Fclass_Guest.php;h=e2911cf3b81709c56e7c094eb4219085c1aeeae9;hp=ec9ef165d5d13e7a8055eba2666acfb1e3a9c9d5;hb=cbd2f71aee1c3daca3d11acc346c79757852316f;hpb=606d43cc38f3cefd2c899f99c03dbd8cfb625441 diff --git a/inc/classes/main/user/guest/class_Guest.php b/inc/classes/main/user/guest/class_Guest.php index ec9ef165..e2911cf3 100644 --- a/inc/classes/main/user/guest/class_Guest.php +++ b/inc/classes/main/user/guest/class_Guest.php @@ -26,6 +26,7 @@ class Guest extends BaseUser implements ManageableGuest, Registerable { const EXCEPTION_USERNAME_NOT_FOUND = 0x170; const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x171; const EXCEPTION_USER_PASS_MISMATCH = 0x172; + const EXCEPTION_USER_NOT_GUEST = 0x173; /** * Protected constructor @@ -45,6 +46,7 @@ class Guest extends BaseUser implements ManageableGuest, Registerable { * @param $userName Username we need a class instance for * @return $userInstance An instance of this user class * @throws UsernameMissingException If the username does not exist + * @throws UserNoGuestException If the user is no guest account */ public static final function createGuestByUsername ($userName) { // Get a new instance @@ -57,7 +59,10 @@ class Guest extends BaseUser implements ManageableGuest, Registerable { if ($userInstance->ifUsernameExists() === FALSE) { // Throw an exception here throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND); - } // END - if + } elseif ($userInstance->isGuest() === FALSE) { + // Sanity check on 'guest' status failed + throw new UserNoGuestException(array($userInstance, $userName), self::EXCEPTION_USER_NOT_GUEST_STATUS); + } // Return the instance return $userInstance;