Code Duplication    Length = 20-24 lines in 3 locations

class.AuthProvider.php 3 locations

@@ 477-497 (lines=21) @@
474
     *
475
     * @return true|false true if the user was successfully created. Otherwise false.
476
     */
477
    public function activatePendingUser($user, $methodName = false)
478
    {
479
        if($methodName === false)
480
        {
481
            $count = count($this->methods);
482
            for($i = 0; $i < $count; $i++)
483
            {
484
                if($this->methods[$i]->current === false) continue;
485
486
                $ret = $this->methods[$i]->activatePendingUser($user);
487
                if($ret !== false)
488
                {
489
                    $this->impersonateUser($ret);
490
                    return true;
491
                }
492
            }
493
            return false;
494
        }
495
        $auth = $this->getAuthenticator($methodName);
496
        return $auth->activatePendingUser($user);
497
    }
498
499
    /**
500
     * Get a current user by a password reset hash
@@ 507-530 (lines=24) @@
504
     *
505
     * @return Auth\User|false The user if the password reset hash is valid. Otherwise false.
506
     */
507
    public function getUserByResetHash($hash, $methodName = false)
508
    {
509
        if($methodName === false)
510
        {
511
            $count = count($this->methods);
512
            for($i = 0; $i < $count; $i++)
513
            {
514
                if($this->methods[$i]->current === false) continue;
515
516
                $ret = $this->methods[$i]->getUserByResetHash($hash);
517
                if($ret !== false)
518
                {
519
                    return $ret;
520
                }
521
            }
522
            return false;
523
        }
524
        $auth = $this->getAuthenticator($methodName);
525
        if($auth === false)
526
        {
527
            return $this->getUserByResetHash($hash, false);
528
        }
529
        return $auth->getUserByResetHash($hash);
530
    }
531
532
    /**
533
     * Get the Auth\Authenticator by host name
@@ 569-588 (lines=20) @@
566
        return true;
567
    }
568
569
    public function getUserByAccessCode($key, $methodName=false)
570
    {
571
        if($methodName === false)
572
        {
573
            $count = count($this->methods);
574
            for($i = 0; $i < $count; $i++)
575
            {
576
                if($this->methods[$i]->current === false) continue;
577
578
                $ret = $this->methods[$i]->getUserByAccessCode($key);
579
                if($ret !== false)
580
                {
581
                    return $ret;
582
                }
583
            }
584
            return false;
585
        }
586
        $auth = $this->getAuthenticator($methodName);
587
        return $auth->getUserByAccessCode($key);
588
    }
589
}
590
/* vim: set tabstop=4 shiftwidth=4 expandtab: */
591
?>