Code Duplication    Length = 20-21 lines in 2 locations

api/v1/users.php 2 locations

@@ 382-401 (lines=20) @@
379
    }
380
}
381
382
function reset_pass($uid)
383
{
384
    global $app;
385
    $auth = AuthProvider::getInstance();
386
    $users = $auth->getUsersByFilter(new \Data\Filter('uid eq '.$uid));
387
    if($users === false || !isset($users[0]))
388
    {
389
        $app->response->setStatus(404);
390
        return;
391
    }
392
    else
393
    {
394
        $email_msg = new PasswordResetEmail($users[0]);
395
        $email_provider = EmailProvider::getInstance();
396
        if($email_provider->sendEmail($email_msg) === false)
397
        {
398
            throw new \Exception('Unable to send email!');
399
        }
400
    }
401
}
402
403
function remind_uid()
404
{
@@ 403-423 (lines=21) @@
400
    }
401
}
402
403
function remind_uid()
404
{
405
    global $app;
406
    $email = $app->request->params('email');
407
    $auth = AuthProvider::getInstance();
408
    $users = $auth->getUsersByFilter(new \Data\Filter('mail eq '.$email));
409
    if($users === false || !isset($users[0]))
410
    {
411
        $app->response->setStatus(404);
412
        return;
413
    }
414
    else
415
    {
416
        $email_msg = new UIDForgotEmail($users[0]);
417
        $email_provider = EmailProvider::getInstance();
418
        if($email_provider->sendEmail($email_msg) === false)
419
        {
420
            throw new \Exception('Unable to send email!');
421
        }
422
    }
423
}
424
/* vim: set tabstop=4 shiftwidth=4 expandtab: */
425
?>
426