Skip to content

Commit 5b462aa

Browse files
committed
light refactoring
1 parent 6581ece commit 5b462aa

File tree

6 files changed

+8
-10
lines changed

6 files changed

+8
-10
lines changed

src/Config/App.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@ class App extends \Config\App
2525
public bool $setUserLibRoutes = true;
2626

2727
/*
28-
*
2928
* Enable Registration
3029
*/
3130
public bool $userCanRegister = true;
3231

3332
/*
34-
* //! not used
3533
* Enable Login
3634
*/
3735
public bool $userCanLogin = true;

src/Config/Routes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
* @var RouteCollection $routes
1515
*/
1616
$routes->match(['get', 'post'], '/login', '\Franky5831\CodeIgniter4UserLibrary\Controllers\User::login', ["as" => "loginurl"]);
17-
$routes->match(['get', 'post'], '/logout', '\Franky5831\CodeIgniter4UserLibrary\Controllers\User::logout', ["as" => "logouturl"]);
1817
$routes->match(['get', 'post'], '/register', '\Franky5831\CodeIgniter4UserLibrary\Controllers\User::register', ["as" => "registerurl"]);
18+
$routes->match(['get'], '/logout', '\Franky5831\CodeIgniter4UserLibrary\Controllers\User::logout', ["as" => "logouturl"]);
1919
}

src/Controllers/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function login(): \CodeIgniter\HTTP\RedirectResponse|string
3939
],
4040
'password' => [
4141
'label' => 'Password',
42-
'rules' => 'required|validateUser[email,password]',
42+
'rules' => 'required|validate_user[email,password]',
4343
],
4444
];
4545

src/Language/en/Validation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
return [
44
'validate_cloudflare_turnstile' => 'Captcha is not valid',
55
'validate_recaptcha_v3' => 'Captcha is not valid',
6-
'validateUser' => 'Email or password are not valid',
7-
'validateXss' => 'The {field} field contains invalid characters',
6+
'validate_user' => 'Email or password are not valid',
7+
'validate_xss' => 'The {field} field contains invalid characters',
88
'user_cant_post' => 'You have exceeded the maximum number of errors. Please try again later.',
99
];

src/Language/it/Validation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
return [
44
'validate_cloudflare_turnstile' => 'Il captcha non è valido',
55
'validate_recaptcha_v3' => 'Il captcha non è valido',
6-
'validateUser' => 'Email o password non sono validi',
7-
'validateXss' => 'Il campo {field} contiene caratteri non consentiti',
6+
'validate_user' => 'Email o password non sono validi',
7+
'validate_xss' => 'Il campo {field} contiene caratteri non consentiti',
88
'user_cant_post' => 'Hai superato il numero massimo di errori. Per favore riprova più tardi.',
99
];

src/Validation/ValidationRules.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function __construct()
1616
$this->antiXss = new AntiXSS();
1717
}
1818

19-
public function validateUser(string $str, string $fields, array $data): bool
19+
public function validate_user(string $str, string $fields, array $data): bool
2020
{
2121
$model = new UserModel();
2222
$user = $model->where("email", $data["email"])->first();
@@ -78,7 +78,7 @@ public function validate_recaptcha_v3(): bool
7878
return (bool) json_decode($curlResult)->success;
7979
}
8080

81-
public function validateXss($str, $fields,): bool
81+
public function validate_xss($str, $fields,): bool
8282
{
8383
$originalValue = $str;
8484
$cleanValue = $this->antiXss->xss_clean($str);

0 commit comments

Comments
 (0)