summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/gallery/helpers/auth.php19
-rw-r--r--modules/rest/controllers/rest.php2
2 files changed, 10 insertions, 11 deletions
diff --git a/modules/gallery/helpers/auth.php b/modules/gallery/helpers/auth.php
index 8c7a0b6d..16f8915a 100644
--- a/modules/gallery/helpers/auth.php
+++ b/modules/gallery/helpers/auth.php
@@ -63,20 +63,19 @@ class auth_Core {
* After there have been 5 failed login attempts, any failure leads to getting locked out for a
* minute.
*/
- static function validate_too_many_failed_logins($name_input) {
- $name = is_object($name_input) ? $name_input->value : $name_input;
+ static function too_many_failed_logins($name) {
$failed_login = ORM::factory("failed_login")
->where("name", "=", $name)
->find();
- if ($failed_login->loaded() &&
- $failed_login->count > 5 &&
- (time() - $failed_login->time < 60)) {
- if (is_object($name_input)) {
- $name_input->add_error("too_many_failed_logins", 1);
- }
- return false;
+ return ($failed_login->loaded() &&
+ $failed_login->count > 5 &&
+ (time() - $failed_login->time < 60));
+ }
+
+ static function validate_too_many_failed_logins($name_input) {
+ if (self::too_many_failed_logins($name_input->value)) {
+ $name_input->add_error("too_many_failed_logins", 1);
}
- return true;
}
/**
diff --git a/modules/rest/controllers/rest.php b/modules/rest/controllers/rest.php
index 64a548d0..9141d6d4 100644
--- a/modules/rest/controllers/rest.php
+++ b/modules/rest/controllers/rest.php
@@ -22,7 +22,7 @@ class Rest_Controller extends Controller {
$username = Input::instance()->post("user");
$password = Input::instance()->post("password");
- if (empty($username) || !auth::validate_too_many_failed_logins($username)) {
+ if (empty($username) || auth::too_many_failed_logins($username)) {
throw new Rest_Exception("Forbidden", 403);
}