summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/auth.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2010-01-30 23:15:18 -0800
committerBharat Mediratta <bharat@menalto.com>2010-01-30 23:15:18 -0800
commitd92ee7954efbf531b40ddd484f76cdfe16c0e53f (patch)
tree441b9d1faf15beff8a16195e8c6e863d666d7db6 /modules/gallery/helpers/auth.php
parent1470b99d1facd07fcb46c0c4e46896d339f5a75a (diff)
Refactory auth::too_many_failed_logins() out of
auth::validate_too_many_failed_logins() to conceptually separate the two.
Diffstat (limited to 'modules/gallery/helpers/auth.php')
-rw-r--r--modules/gallery/helpers/auth.php19
1 files changed, 9 insertions, 10 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;
}
/**