예제 #1
0
                 if (!$u->hasStillUser()) {
                     throw new \Exception('You can not delete the only remaining user.');
                 }
                 if (!$u->delete()) {
                     throw new \Exception('Unable to delete the user. Please contact the webmaster.');
                 }
                 $this->removeExtendedToken($this->request(4));
                 header('Location: ' . $this->URL('manage/users?deleted'));
                 exit;
             } catch (\Exception $e) {
                 $this->assign('form_error', $e->getMessage());
             }
         }
         $this->page('manage/users/delete');
         $this->getToken();
         $this->assign('user', array('id' => $u->getId(), 'email' => $u->getEmail()));
         break;
     case NULL:
         $this->page('manage/users');
         $this->getExtendedToken();
         $this->assign('users', User::getUsers());
         if (isset($_GET['created'])) {
             $this->assign('message', 'The user has been created.');
         } else {
             if (isset($_GET['deleted'])) {
                 $this->assign('message', 'The user has been deleted.');
             }
         }
         break;
 }
 break;
예제 #2
0
$this->canLogin();
if ($this->auth->isLogged()) {
    header('Location: ' . $this->URL('manage'));
    exit;
}
if (!empty($_POST)) {
    $this->acceptToken();
    try {
        $this->assign('form_data', array('email' => htmlspecialchars($_POST['email']), 'remember' => !empty($_POST['remember']) && $_POST['remember'] == 'on'));
        if (empty($_POST['email']) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
            throw new \Exception('Please enter a valid email address.');
        }
        if (empty($_POST['pass'])) {
            throw new \Exception('Please enter a valid password.');
        }
        $u = new User();
        if (!$u->acceptCredential($_POST['email'], $_POST['pass'])) {
            $this->auth->addFailure();
            $this->canLogin();
            throw new \Exception('I’m so sorry but I can’t accept your credential… Please try again.');
        }
        $u->registerLogin();
        $this->auth->login($u->getId());
        header('Location: ' . $this->URL('manage'));
        exit;
    } catch (\Exception $e) {
        $this->assign('form_error', $e->getMessage());
    }
}
$this->page('authentification');
$this->getToken();