| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | namespace Aurora\Modules\StandardRegisterFormWebclient; |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | class Module extends \Aurora\System\Module\AbstractWebclientModule |
| 22: | { |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | public static function getInstance() |
| 29: | { |
| 30: | return parent::getInstance(); |
| 31: | } |
| 32: | |
| 33: | |
| 34: | |
| 35: | |
| 36: | public static function Decorator() |
| 37: | { |
| 38: | return parent::Decorator(); |
| 39: | } |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | public function getModuleSettings() |
| 45: | { |
| 46: | return $this->oModuleSettings; |
| 47: | } |
| 48: | |
| 49: | |
| 50: | |
| 51: | |
| 52: | |
| 53: | |
| 54: | public function GetSettings() |
| 55: | { |
| 56: | \Aurora\System\Api::checkUserRoleIsAtLeast(\Aurora\System\Enums\UserRole::Anonymous); |
| 57: | |
| 58: | return array( |
| 59: | 'ServerModuleName' => $this->oModuleSettings->ServerModuleName, |
| 60: | 'HashModuleName' => $this->oModuleSettings->HashModuleName, |
| 61: | 'CustomLogoUrl' => $this->oModuleSettings->CustomLogoUrl, |
| 62: | 'InfoText' => $this->oModuleSettings->InfoText, |
| 63: | 'BottomInfoHtmlText' => $this->oModuleSettings->BottomInfoHtmlText, |
| 64: | ); |
| 65: | } |
| 66: | |
| 67: | |
| 68: | |
| 69: | |
| 70: | |
| 71: | |
| 72: | |
| 73: | |
| 74: | |
| 75: | |
| 76: | public function Register($Login, $Password, $UserId) |
| 77: | { |
| 78: | \Aurora\System\Api::checkUserRoleIsAtLeast(\Aurora\System\Enums\UserRole::Anonymous); |
| 79: | |
| 80: | if (\Aurora\System\Api::getAuthenticatedUserId()) { |
| 81: | return false; |
| 82: | } |
| 83: | |
| 84: | if (empty($UserId)) { |
| 85: | $bPrevState = \Aurora\System\Api::skipCheckUserRole(true); |
| 86: | |
| 87: | $UserId = \Aurora\Modules\Core\Module::Decorator()->CreateUser(0, $Login); |
| 88: | |
| 89: | \Aurora\System\Api::skipCheckUserRole($bPrevState); |
| 90: | } |
| 91: | |
| 92: | if (empty($UserId)) { |
| 93: | throw new \Aurora\System\Exceptions\ApiException(\Aurora\System\Notifications::InvalidInputParameter); |
| 94: | } |
| 95: | |
| 96: | $mResult = false; |
| 97: | |
| 98: | $refArgs = array( |
| 99: | 'Login' => $Login, |
| 100: | 'Password' => $Password, |
| 101: | 'UserId' => $UserId, |
| 102: | ); |
| 103: | $this->broadcastEvent( |
| 104: | 'Register', |
| 105: | $refArgs, |
| 106: | $mResult |
| 107: | ); |
| 108: | |
| 109: | if (!empty($mResult)) { |
| 110: | $oLoginDecorator = \Aurora\Modules\StandardLoginFormWebclient\Module::Decorator(); |
| 111: | $mResult = $oLoginDecorator->Login($Login, $Password); |
| 112: | if ($mResult && isset($mResult['AuthToken'])) { |
| 113: | \Aurora\System\Api::getAuthenticatedUserId($mResult['AuthToken']); |
| 114: | } |
| 115: | } |
| 116: | |
| 117: | return $mResult; |
| 118: | } |
| 119: | |
| 120: | } |
| 121: | |