Skip to content

Instantly share code, notes, and snippets.

@drmmr763
Last active September 9, 2015 02:52
Show Gist options
  • Save drmmr763/584ecf12d7179dee927f to your computer and use it in GitHub Desktop.
Save drmmr763/584ecf12d7179dee927f to your computer and use it in GitHub Desktop.
<?php
try {
$app->post('/login', function () use ($app, $userModel) {
if ( ! $userModel->login($_POST['username'], $_POST['password'])===true){
throw new \Exception('Login failed, please check username/password and try again');
}
$app->redirect('/');
});
} catch (\Exception $e) {
// halts the app here
$app->render('login.twig', array($e->getMessage()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment