session_destroy(); F3::reroute('/'); } F3::route('GET /', function () { $facebook = F3::get('Facebook'); $uid = $facebook->getUser(); // Check if they are "logged in" by session, if they arent't, // generate a Login URL and MAKE them sign in... if (!$uid) { $scope = array('offline_access', 'read_friendlists', 'email', 'user_relationships', 'user_relationship_details', 'friends_relationship_details', 'friends_relationships', 'manage_friendlists', 'read_stream', 'read_friendlists'); $login_url = $facebook->getLoginUrl(array('redirect_uri' => F3::get('FACEBOOK.redirect_uri'), 'scope' => implode(',', $scope))); F3::set('login_url', $login_url); // Load the header template F3::set('extra_css', array('home.css')); echo Template::serve('templates/header.html'); echo F3::render('templates/index.html'); // Load the footer template F3::set('extra_js', array('bootstrap-collapse.js')); echo Template::serve('templates/footer.html'); die; } //If they are logged, let's render the dashboard // We need to store "user" for later use in the template // http://fatfree.sourceforge.net/page/data-mappers/beyond-crud $user = new Axon('user'); $user->load(array('fb_id=:fb_id', array(':fb_id' => $uid))); // They shouldn't be able to access they dashboard if they're // not in our database... if ($user->dry()) { _force_logout(); }