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