$sessionStatus = 'direct';
    }
    $app->view->setData(array('pageTitle' => 'Advanced Tissue Client Portal Login', 'referrer' => $sessionStatus, 'redirect' => $redirect));
    $app->render('loginForm.php');
});
$app->post('/login/authenticate/', function () use($app) {
    if (isset($_POST['inputEmail']) && isset($_POST['inputPassword']) && $_POST['inputPassword'] != "") {
        //@TODO - Revisit this to explore sanitizing inputs from $_POST array
        $userID = $_POST['inputEmail'];
        $password = $_POST['inputPassword'];
        try {
            $user = new \OnlineOrders\User($userID);
            if ($user->userInfo['ChangePass']) {
                $app->redirect("/login/passwordChange/" . $userID . "/");
            } else {
                $user->authenticate($password);
                $app->redirect("/account/home/");
            }
        } catch (Exception $e) {
            //@TODO - Create error handler page that prettifies error messages.
            echo 'Message: ' . $e->getMessage();
            $app->view->setData(array('pageTitle' => 'Advanced Tissue Client Portal Login', 'referrer' => $e->getMessage(), 'persistentEmail' => $_POST['inputEmail']));
            $app->render('loginForm.php');
        }
    } else {
        echo "something went wrong here!";
        print_r($_POST);
    }
});
/**
*