@@ -21,7 +21,7 @@ |
||
21 | 21 | |
22 | 22 | public function handle() : Template\Block { |
23 | 23 | |
24 | - if (Auth::isInitial()) Request::redirect(INSTALL_PATH . '/admin/register'); |
|
24 | + if (Auth::isInitial()) Request::redirect(INSTALL_PATH.'/admin/register'); |
|
25 | 25 | |
26 | 26 | return (new Auth\Action\Login)->handle(); |
27 | 27 | } |
@@ -21,7 +21,9 @@ |
||
21 | 21 | |
22 | 22 | public function handle() : Template\Block { |
23 | 23 | |
24 | - if (Auth::isInitial()) Request::redirect(INSTALL_PATH . '/admin/register'); |
|
24 | + if (Auth::isInitial()) { |
|
25 | + Request::redirect(INSTALL_PATH . '/admin/register'); |
|
26 | + } |
|
25 | 27 | |
26 | 28 | return (new Auth\Action\Login)->handle(); |
27 | 29 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | |
22 | 22 | public function handle() : Template\Block { |
23 | 23 | |
24 | - if (!Auth::isInitial()) Request::redirect(INSTALL_PATH . '/admin/login'); |
|
24 | + if (!Auth::isInitial()) Request::redirect(INSTALL_PATH.'/admin/login'); |
|
25 | 25 | |
26 | 26 | return (new Auth\Action\Register)->handle(); |
27 | 27 | } |
@@ -21,7 +21,9 @@ |
||
21 | 21 | |
22 | 22 | public function handle() : Template\Block { |
23 | 23 | |
24 | - if (!Auth::isInitial()) Request::redirect(INSTALL_PATH . '/admin/login'); |
|
24 | + if (!Auth::isInitial()) { |
|
25 | + Request::redirect(INSTALL_PATH . '/admin/login'); |
|
26 | + } |
|
25 | 27 | |
26 | 28 | return (new Auth\Action\Register)->handle(); |
27 | 29 | } |
@@ -37,7 +37,7 @@ |
||
37 | 37 | |
38 | 38 | if (false === ($result = Auth\Utils\Connector\Secret::authorize($code, $admin))) { |
39 | 39 | |
40 | - Request::redirect(INSTALL_PATH . ($admin ? '/admin' : '/profile') . '/reset'); |
|
40 | + Request::redirect(INSTALL_PATH.($admin ? '/admin' : '/profile').'/reset'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | # Set recovery data |
@@ -29,19 +29,29 @@ |
||
29 | 29 | |
30 | 30 | # Check code |
31 | 31 | |
32 | - if (false === ($code = Validate::authCode($code))) return false; |
|
32 | + if (false === ($code = Validate::authCode($code))) { |
|
33 | + return false; |
|
34 | + } |
|
33 | 35 | |
34 | 36 | # Get auth |
35 | 37 | |
36 | - if (!($auth = Entitizer::get(static::$type))->init($code, 'code')) return false; |
|
38 | + if (!($auth = Entitizer::get(static::$type))->init($code, 'code')) { |
|
39 | + return false; |
|
40 | + } |
|
37 | 41 | |
38 | - if (($auth->ip !== REQUEST_CLIENT_IP) || ($auth->time < (REQUEST_TIME - static::$lifetime))) return false; |
|
42 | + if (($auth->ip !== REQUEST_CLIENT_IP) || ($auth->time < (REQUEST_TIME - static::$lifetime))) { |
|
43 | + return false; |
|
44 | + } |
|
39 | 45 | |
40 | 46 | # Get user |
41 | 47 | |
42 | - if (0 === ($user = Entitizer::get(TABLE_USERS, $auth->id))->id) return false; |
|
48 | + if (0 === ($user = Entitizer::get(TABLE_USERS, $auth->id))->id) { |
|
49 | + return false; |
|
50 | + } |
|
43 | 51 | |
44 | - if ($user->rank < ($admin ? RANK_ADMINISTRATOR : RANK_USER)) return false; |
|
52 | + if ($user->rank < ($admin ? RANK_ADMINISTRATOR : RANK_USER)) { |
|
53 | + return false; |
|
54 | + } |
|
45 | 55 | |
46 | 56 | # ------------------------ |
47 | 57 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | private function getContents() : Template\Block { |
29 | 29 | |
30 | - $contents = View::get((Auth::isAdmin() ? 'Blocks/Auth/' : 'Blocks/Profile/Auth/') . static::$view); |
|
30 | + $contents = View::get((Auth::isAdmin() ? 'Blocks/Auth/' : 'Blocks/Profile/Auth/').static::$view); |
|
31 | 31 | |
32 | 32 | # Set code |
33 | 33 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | if ($this->form->handle(new static::$controller_class($this->user))) { |
58 | 58 | |
59 | - Request::redirect(INSTALL_PATH . (Auth::isAdmin() ? '/admin' : '/profile') . static::$redirect); |
|
59 | + Request::redirect(INSTALL_PATH.(Auth::isAdmin() ? '/admin' : '/profile').static::$redirect); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | # Display success message |
@@ -31,11 +31,15 @@ discard block |
||
31 | 31 | |
32 | 32 | # Set code |
33 | 33 | |
34 | - if (null !== $this->code) $contents->code = $this->code; |
|
34 | + if (null !== $this->code) { |
|
35 | + $contents->code = $this->code; |
|
36 | + } |
|
35 | 37 | |
36 | 38 | # Implement form |
37 | 39 | |
38 | - if (null !== $this->form) $this->form->implement($contents); |
|
40 | + if (null !== $this->form) { |
|
41 | + $this->form->implement($contents); |
|
42 | + } |
|
39 | 43 | |
40 | 44 | # ------------------------ |
41 | 45 | |
@@ -61,10 +65,12 @@ discard block |
||
61 | 65 | |
62 | 66 | # Display success message |
63 | 67 | |
64 | - foreach (static::$messages as $key => $message) if (Request::get('submitted') === $key) { |
|
68 | + foreach (static::$messages as $key => $message) { |
|
69 | + if (Request::get('submitted') === $key) { |
|
65 | 70 | |
66 | 71 | Messages::set('success', Language::get($message['text']), Language::get($message['title'])); |
67 | 72 | } |
73 | + } |
|
68 | 74 | |
69 | 75 | # ------------------------ |
70 | 76 |
@@ -19,13 +19,13 @@ discard block |
||
19 | 19 | |
20 | 20 | private static function send(Entitizer\Entity\User $user, string $view, string $subject, string $link) : bool { |
21 | 21 | |
22 | - $message = View::get((Auth::isAdmin() ? 'Blocks/Auth/Mail/' : 'Blocks/Profile/Auth/Mail/') . $view); |
|
22 | + $message = View::get((Auth::isAdmin() ? 'Blocks/Auth/Mail/' : 'Blocks/Profile/Auth/Mail/').$view); |
|
23 | 23 | |
24 | 24 | $message->name = $user->name; $message->link = $link; $message->copyright = Date::getYear(); |
25 | 25 | |
26 | 26 | $to = $user->email; $sender = Settings::get('site_title'); $reply_to = Settings::get('system_email'); |
27 | 27 | |
28 | - $from = ((false !== ($host = parse_url(Settings::get('system_url'), PHP_URL_HOST))) ? ('noreply@' . $host) : ''); |
|
28 | + $from = ((false !== ($host = parse_url(Settings::get('system_url'), PHP_URL_HOST))) ? ('noreply@'.$host) : ''); |
|
29 | 29 | |
30 | 30 | # ------------------------ |
31 | 31 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | public static function sendPasswordMessage(Entitizer\Entity\User $user, string $code) : bool { |
40 | 40 | |
41 | - $link = (Settings::get('system_url') . (Auth::isAdmin() ? '/admin' : '/profile') . '/recover?code=' . $code); |
|
41 | + $link = (Settings::get('system_url').(Auth::isAdmin() ? '/admin' : '/profile').'/recover?code='.$code); |
|
42 | 42 | |
43 | 43 | return self::send($user, 'Reset', Language::get('MAIL_SUBJECT_RESET'), $link); |
44 | 44 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | public static function sendRegistrationMessage(Entitizer\Entity\User $user) : bool { |
51 | 51 | |
52 | - $link = (Settings::get('system_url') . (Auth::isAdmin() ? '/admin' : '/profile')); |
|
52 | + $link = (Settings::get('system_url').(Auth::isAdmin() ? '/admin' : '/profile')); |
|
53 | 53 | |
54 | 54 | return self::send($user, 'Register', Language::get('MAIL_SUBJECT_REGISTER'), $link); |
55 | 55 | } |
@@ -87,7 +87,7 @@ |
||
87 | 87 | |
88 | 88 | public static function isInitial() : bool { |
89 | 89 | |
90 | - DB::send("SHOW TABLE STATUS WHERE name LIKE '" . TABLE_USERS . "'"); |
|
90 | + DB::send("SHOW TABLE STATUS WHERE name LIKE '".TABLE_USERS."'"); |
|
91 | 91 | |
92 | 92 | if (!(DB::getLast() && (null !== ($data = DB::getLast()->getRow())))) return false; |
93 | 93 |
@@ -31,11 +31,15 @@ discard block |
||
31 | 31 | |
32 | 32 | # Check session code |
33 | 33 | |
34 | - if (!is_string($code = Session::get('code'))) return false; |
|
34 | + if (!is_string($code = Session::get('code'))) { |
|
35 | + return false; |
|
36 | + } |
|
35 | 37 | |
36 | 38 | # Authorize |
37 | 39 | |
38 | - if (false === ($result = Auth\Utils\Connector\Session::authorize($code, self::$admin))) return false; |
|
40 | + if (false === ($result = Auth\Utils\Connector\Session::authorize($code, self::$admin))) { |
|
41 | + return false; |
|
42 | + } |
|
39 | 43 | |
40 | 44 | # Update auth |
41 | 45 | |
@@ -62,7 +66,9 @@ discard block |
||
62 | 66 | |
63 | 67 | public static function logout() : bool { |
64 | 68 | |
65 | - if ((null === self::$user) || (0 === self::$user->id)) return false; |
|
69 | + if ((null === self::$user) || (0 === self::$user->id)) { |
|
70 | + return false; |
|
71 | + } |
|
66 | 72 | |
67 | 73 | # Remove auth entry from db |
68 | 74 | |
@@ -89,7 +95,9 @@ discard block |
||
89 | 95 | |
90 | 96 | DB::send("SHOW TABLE STATUS WHERE name LIKE '" . TABLE_USERS . "'"); |
91 | 97 | |
92 | - if (!(DB::getLast() && (null !== ($data = DB::getLast()->getRow())))) return false; |
|
98 | + if (!(DB::getLast() && (null !== ($data = DB::getLast()->getRow())))) { |
|
99 | + return false; |
|
100 | + } |
|
93 | 101 | |
94 | 102 | # ------------------------ |
95 | 103 |
@@ -44,13 +44,15 @@ discard block |
||
44 | 44 | |
45 | 45 | # Validate values |
46 | 46 | |
47 | - if (false === ($password_new = Validate::userPassword($password_new))) |
|
48 | - |
|
47 | + if (false === ($password_new = Validate::userPassword($password_new))) { |
|
48 | + |
|
49 | 49 | return ['password_new', 'USER_ERROR_PASSWORD_NEW_INVALID']; |
50 | + } |
|
50 | 51 | |
51 | - if (0 !== strcmp($password_new, $password_retype)) |
|
52 | - |
|
52 | + if (0 !== strcmp($password_new, $password_retype)) { |
|
53 | + |
|
53 | 54 | return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH']; |
55 | + } |
|
54 | 56 | |
55 | 57 | # Encode password |
56 | 58 | |
@@ -60,7 +62,9 @@ discard block |
||
60 | 62 | |
61 | 63 | $data = ['auth_key' => $auth_key, 'password' => $password]; |
62 | 64 | |
63 | - if (!$this->user->edit($data)) return 'USER_ERROR_AUTH_RECOVER'; |
|
65 | + if (!$this->user->edit($data)) { |
|
66 | + return 'USER_ERROR_AUTH_RECOVER'; |
|
67 | + } |
|
64 | 68 | |
65 | 69 | # Remove secret |
66 | 70 |
@@ -56,7 +56,7 @@ |
||
56 | 56 | |
57 | 57 | if ((!$this->user->init($$init_by, $init_by)) || (Auth::isAdmin() && ($this->user->rank < RANK_ADMINISTRATOR))) { |
58 | 58 | |
59 | - return ['name_email', ('USER_ERROR_' . strtoupper($init_by) .'_INCORRECT')]; |
|
59 | + return ['name_email', ('USER_ERROR_'.strtoupper($init_by).'_INCORRECT')]; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | # Check access |
@@ -46,9 +46,13 @@ discard block |
||
46 | 46 | |
47 | 47 | if ((false === ($name = Validate::userName($name_email))) && |
48 | 48 | |
49 | - (false === ($email = Validate::userEmail($name_email)))) return ['name_email', 'USER_ERROR_NAME_INVALID']; |
|
49 | + (false === ($email = Validate::userEmail($name_email)))) { |
|
50 | + return ['name_email', 'USER_ERROR_NAME_INVALID']; |
|
51 | + } |
|
50 | 52 | |
51 | - if (false === Security::checkCaptcha($captcha)) return ['captcha', 'USER_ERROR_CAPTCHA_INCORRECT']; |
|
53 | + if (false === Security::checkCaptcha($captcha)) { |
|
54 | + return ['captcha', 'USER_ERROR_CAPTCHA_INCORRECT']; |
|
55 | + } |
|
52 | 56 | |
53 | 57 | # Init user |
54 | 58 | |
@@ -61,7 +65,9 @@ discard block |
||
61 | 65 | |
62 | 66 | # Check access |
63 | 67 | |
64 | - if (!Auth::isAdmin() && ($this->user->rank === RANK_GUEST)) return 'USER_ERROR_ACCESS'; |
|
68 | + if (!Auth::isAdmin() && ($this->user->rank === RANK_GUEST)) { |
|
69 | + return 'USER_ERROR_ACCESS'; |
|
70 | + } |
|
65 | 71 | |
66 | 72 | # Create secret |
67 | 73 | |
@@ -71,7 +77,9 @@ discard block |
||
71 | 77 | |
72 | 78 | $data = ['id' => $this->user->id, 'code' => $code, 'ip' => $ip, 'time' => $time]; |
73 | 79 | |
74 | - if (!$secret->create($data)) return 'USER_ERROR_AUTH_RESET'; |
|
80 | + if (!$secret->create($data)) { |
|
81 | + return 'USER_ERROR_AUTH_RESET'; |
|
82 | + } |
|
75 | 83 | |
76 | 84 | # Send mail |
77 | 85 |