Passed
Pull Request — master (#17)
by Anton
03:14
created
www/engine/System/Classes/Modules/Auth/Action/Recover.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Auth/Utils/Connector.php 1 patch
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,19 +29,29 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Auth/Utils/Action.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,11 +31,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Auth/Utils/Mail.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,13 +19,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Auth/Auth.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,11 +31,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Auth/Controller/Recover.php 1 patch
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -44,13 +44,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Auth/Controller/Reset.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -46,9 +46,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Auth/Controller/Login.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
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 password
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -46,9 +46,13 @@  discard block
 block discarded – undo
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 === ($password = Validate::userPassword($password))) return ['password', 'USER_ERROR_PASSWORD_INVALID'];
53
+			if (false === ($password = Validate::userPassword($password))) {
54
+				return ['password', 'USER_ERROR_PASSWORD_INVALID'];
55
+			}
52 56
 
53 57
 			# Init user
54 58
 
@@ -63,11 +67,15 @@  discard block
 block discarded – undo
63 67
 
64 68
 			$password = Str::encode($this->user->auth_key, $password);
65 69
 
66
-			if (0 !== strcmp($this->user->password, $password)) return ['password', 'USER_ERROR_PASSWORD_INCORRECT'];
70
+			if (0 !== strcmp($this->user->password, $password)) {
71
+				return ['password', 'USER_ERROR_PASSWORD_INCORRECT'];
72
+			}
67 73
 
68 74
 			# Check access
69 75
 
70
-			if (!Auth::isAdmin() && ($this->user->rank === RANK_GUEST)) return 'USER_ERROR_ACCESS';
76
+			if (!Auth::isAdmin() && ($this->user->rank === RANK_GUEST)) {
77
+				return 'USER_ERROR_ACCESS';
78
+			}
71 79
 
72 80
 			# Create session
73 81
 
@@ -77,7 +85,9 @@  discard block
 block discarded – undo
77 85
 
78 86
 			$data = ['id' => $this->user->id, 'code' => $code, 'ip' => $ip, 'time' => $time];
79 87
 
80
-			if (!$session->create($data)) return 'USER_ERROR_AUTH_LOGIN';
88
+			if (!$session->create($data)) {
89
+				return 'USER_ERROR_AUTH_LOGIN';
90
+			}
81 91
 
82 92
 			# Set session variable
83 93
 
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Auth/Controller/Register.php 1 patch
Braces   +30 added lines, -10 removed lines patch added patch discarded remove patch
@@ -44,27 +44,45 @@  discard block
 block discarded – undo
44 44
 
45 45
 			# Validate values
46 46
 
47
-			if (false === ($name = Validate::userName($name))) return ['name', 'USER_ERROR_NAME_INVALID'];
47
+			if (false === ($name = Validate::userName($name))) {
48
+				return ['name', 'USER_ERROR_NAME_INVALID'];
49
+			}
48 50
 
49
-			if (false === ($password = Validate::userPassword($password))) return ['password', 'USER_ERROR_PASSWORD_INVALID'];
51
+			if (false === ($password = Validate::userPassword($password))) {
52
+				return ['password', 'USER_ERROR_PASSWORD_INVALID'];
53
+			}
50 54
 
51
-			if (false === ($email = Validate::userEmail($email))) return ['email', 'USER_ERROR_EMAIL_INVALID'];
55
+			if (false === ($email = Validate::userEmail($email))) {
56
+				return ['email', 'USER_ERROR_EMAIL_INVALID'];
57
+			}
52 58
 
53
-			if (0 !== strcmp($password, $password_retype)) return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH'];
59
+			if (0 !== strcmp($password, $password_retype)) {
60
+				return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH'];
61
+			}
54 62
 
55
-			if (false === Security::checkCaptcha($captcha)) return ['captcha', 'USER_ERROR_CAPTCHA_INCORRECT'];
63
+			if (false === Security::checkCaptcha($captcha)) {
64
+				return ['captcha', 'USER_ERROR_CAPTCHA_INCORRECT'];
65
+			}
56 66
 
57 67
 			# Check name exists
58 68
 
59
-			if (false === ($check_name = $this->user->check($name, 'name'))) return 'USER_ERROR_AUTH_REGISTER';
69
+			if (false === ($check_name = $this->user->check($name, 'name'))) {
70
+				return 'USER_ERROR_AUTH_REGISTER';
71
+			}
60 72
 
61
-			if ($check_name === 1) return ['name', 'USER_ERROR_NAME_DUPLICATE'];
73
+			if ($check_name === 1) {
74
+				return ['name', 'USER_ERROR_NAME_DUPLICATE'];
75
+			}
62 76
 
63 77
 			# Check email exists
64 78
 
65
-			if (false === ($check_email = $this->user->check($email, 'email'))) return 'USER_ERROR_AUTH_REGISTER';
79
+			if (false === ($check_email = $this->user->check($email, 'email'))) {
80
+				return 'USER_ERROR_AUTH_REGISTER';
81
+			}
66 82
 
67
-			if ($check_email === 1) return ['email', 'USER_ERROR_EMAIL_DUPLICATE'];
83
+			if ($check_email === 1) {
84
+				return ['email', 'USER_ERROR_EMAIL_DUPLICATE'];
85
+			}
68 86
 
69 87
 			# Encode password
70 88
 
@@ -87,7 +105,9 @@  discard block
 block discarded – undo
87 105
 			$data['time_registered']    = REQUEST_TIME;
88 106
 			$data['time_logged']        = REQUEST_TIME;
89 107
 
90
-			if (!$this->user->create($data)) return 'USER_ERROR_AUTH_REGISTER';
108
+			if (!$this->user->create($data)) {
109
+				return 'USER_ERROR_AUTH_REGISTER';
110
+			}
91 111
 
92 112
 			# Send mail
93 113
 
Please login to merge, or discard this patch.