/** * Clears contents from storage * * @throws Zend_Auth_Storage_Exception If clearing contents from * storage is impossible * @return void */ public function clear() { $this->app->deleteCookie($this->cookieName); }
// OK echo json_encode(array('operation' => 'login', 'status' => 'ok')); } else { throw new AuthenticateFailedException(); } } catch (AuthenticateFailedException $e) { $app->response()->status(401); $app->response()->header('X-Status-Reason', 'Login failure'); } catch (Exception $e) { $app->response()->status(400); $app->response()->header('X-Status-Reason', $e->getMessage()); } }); $app->get('/logout', function () use($app) { try { $app->deleteCookie('username'); $app->deleteCookie('password'); $app->response()->header('Content-Type', 'application/json'); $app->response()->status(200); // OK echo json_encode(array('operation' => 'logout', 'status' => 'ok')); } catch (Exception $e) { $app->response()->status(400); $app->response()->header('X-Status-Reason', $e->getMessage()); } }); // API for CRUD operations on articles // handle GET requests for /index.php/articles $app->get('/articles', $authenticateUser($app), function () use($app) { // query database for all articles $articles = R::find('articles');
$app->flash('error', 'Too many failed attempts. Try again later.'); $app->redirect($app->urlFor('login')); } } else { $app->flash('error', "All Fields Required"); $app->redirect($app->urlFor('login')); } // END Required fields }); // Logout page $app->get("/logout", function () use($app, $dl) { // Remove the session id from the database // logout($username); unset($_SESSION['usr']); unset($_SESSION['sid']); $app->deleteCookie('urlRedirect'); $app->view()->setData('usr', null); $app->flash('loggedout', 'You\'ve been logged out'); $app->redirect($app->urlFor('login')); }); // Temporary Admin Page $app->get('/admin', $authenticate($app, $dl), function () use($app) { $app->redirect($app->urlFor('login')); })->name('admin'); // Admin Dashboard $app->get('/admin/dashboard', $authenticate($app, $dl), function () use($app, $dl) { $app->render('dashboard.twig', array('albums' => $dl->get_albums(), 'redeemed' => $dl->admin->display_emails())); })->name('dashboard'); $app->post('/admin/dashboard', $authenticate($app, $dl), function () use($app, $dl) { $track_album = $app->request->post('album_codes'); $tracks = $app->request->post('album_track');